diff --git a/app/code/Magento/Checkout/Model/Type/Onepage.php b/app/code/Magento/Checkout/Model/Type/Onepage.php
index 775c0dcb632322ab0ab4daa3c8300c4ae8d8ed8c..8d9f2ed620c1ab9c79059480f38ddb6006f5625a 100644
--- a/app/code/Magento/Checkout/Model/Type/Onepage.php
+++ b/app/code/Magento/Checkout/Model/Type/Onepage.php
@@ -379,149 +379,6 @@ class Onepage
         return [];
     }
 
-    /**
-     * Save billing address information to quote
-     * This method is called by One Page Checkout JS (AJAX) while saving the billing information.
-     *
-     * @param   array $data
-     * @param   int $customerAddressId
-     * @return  array
-     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
-     * @SuppressWarnings(PHPMD.NPathComplexity)
-     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
-     */
-    public function saveBilling($data, $customerAddressId)
-    {
-        if (empty($data)) {
-            return ['error' => -1, 'message' => __('Invalid data')];
-        }
-
-        $address = $this->getQuote()->getBillingAddress();
-        $addressForm = $this->_formFactory->create(
-            AddressMetadata::ENTITY_TYPE_ADDRESS,
-            'customer_address_edit',
-            [],
-            $this->_request->isAjax(),
-            Form::IGNORE_INVISIBLE,
-            []
-        );
-
-        if ($customerAddressId) {
-            try {
-                $customerAddress = $this->addressRepository->getById($customerAddressId);
-                if ($customerAddress->getCustomerId() != $this->getQuote()->getCustomerId()) {
-                    return ['error' => 1, 'message' => __('The customer address is not valid.')];
-                }
-                $address->importCustomerAddressData($customerAddress)->setSaveInAddressBook(0);
-            } catch (\Exception $e) {
-                return ['error' => 1, 'message' => __('Address does not exist.')];
-            }
-        } else {
-            // emulate request object
-            $addressData = $addressForm->extractData($addressForm->prepareRequest($data));
-            $addressErrors = $addressForm->validateData($addressData);
-            if ($addressErrors !== true) {
-                return ['error' => 1, 'message' => array_values($addressErrors)];
-            }
-            $address->addData($addressForm->compactData($addressData));
-            //unset billing address attributes which were not shown in form
-            foreach ($addressForm->getAttributes() as $attribute) {
-                if (!isset($data[$attribute->getAttributeCode()])) {
-                    $address->setData($attribute->getAttributeCode(), null);
-                }
-            }
-            $address->setCustomerAddressId(null);
-            // Additional form data, not fetched by extractData (as it fetches only attributes)
-            $address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);
-            $this->getQuote()->setBillingAddress($address);
-        }
-
-        // validate billing address
-        if (($validateRes = $address->validate()) !== true) {
-            return ['error' => 1, 'message' => $validateRes];
-        }
-
-        if (true !== ($result = $this->_validateCustomerData($data))) {
-            return $result;
-        } else {
-            /** Even though _validateCustomerData should not modify data, it does */
-            $address = $this->getQuote()->getBillingAddress();
-        }
-
-        if (!$this->getQuote()->getCustomerId() && $this->isCheckoutMethodRegister()) {
-            if ($this->_customerEmailExists($address->getEmail(), $this->_storeManager->getWebsite()->getId())) {
-                return [
-                    'error' => 1,
-                    // @codingStandardsIgnoreStart
-                    'message' => __(
-                        'This email address already belongs to a registered customer. You can sign in or create an account with a different email address.'
-                    )
-                    // @codingStandardsIgnoreEnd
-                ];
-            }
-        }
-
-        if (!$this->getQuote()->isVirtual()) {
-            /**
-             * Billing address using options
-             */
-            $usingCase = isset($data['use_for_shipping'])
-                ? (bool)$data['use_for_shipping']
-                : self::NOT_USE_FOR_SHIPPING;
-
-            switch ($usingCase) {
-                case self::NOT_USE_FOR_SHIPPING:
-                    $shipping = $this->getQuote()->getShippingAddress();
-                    $shipping->setSameAsBilling(0);
-                    $shipping->save();
-                    break;
-                case self::USE_FOR_SHIPPING:
-                    $billing = clone $address;
-                    $billing->unsAddressId()->unsAddressType();
-                    $shipping = $this->getQuote()->getShippingAddress();
-                    $shippingMethod = $shipping->getShippingMethod();
-
-                    // Billing address properties that must be always copied to shipping address
-                    $requiredBillingAttributes = ['customer_address_id'];
-
-                    // don't reset original shipping data, if it was not changed by customer
-                    foreach ($shipping->getData() as $shippingKey => $shippingValue) {
-                        if ($shippingValue !== null
-                            && $billing->getData($shippingKey) !== null
-                            && !isset($data[$shippingKey])
-                            && !in_array($shippingKey, $requiredBillingAttributes)
-                        ) {
-                            $billing->unsetData($shippingKey);
-                        }
-                    }
-                    $shipping->addData($billing->getData())
-                        ->setSameAsBilling(1)
-                        ->setSaveInAddressBook(0)
-                        ->setShippingMethod($shippingMethod)
-                        ->setCollectShippingRates(true);
-                    $this->totalsCollector->collectAddressTotals($this->getQuote(), $shipping);
-
-                    if (!$this->isCheckoutMethodRegister()) {
-                        $shipping->save();
-                    }
-                    $this->getCheckout()->setStepData('shipping', 'complete', true);
-                    break;
-            }
-        }
-
-        if ($this->isCheckoutMethodRegister()) {
-            $this->quoteRepository->save($this->getQuote());
-        } else {
-            $address->save();
-        }
-
-        $this->getCheckout()
-            ->setStepData('billing', 'allow', true)
-            ->setStepData('billing', 'complete', true)
-            ->setStepData('shipping', 'allow', true);
-        return [];
-    }
-
     /**
      * Check whether checkout method is "register"
      *
@@ -532,100 +389,6 @@ class Onepage
         return $this->getQuote()->getCheckoutMethod() == self::METHOD_REGISTER;
     }
 
-    /**
-     * Validate customer data and set some its data for further usage in quote
-     *
-     * Will return either true or array with error messages
-     *
-     * @param array $data
-     * @return bool|array
-     */
-    protected function _validateCustomerData(array $data)
-    {
-        $quote = $this->getQuote();
-        $isCustomerNew = !$quote->getCustomerId();
-        $customer = $quote->getCustomer();
-        $customerData = $this->extensibleDataObjectConverter->toFlatArray(
-            $customer,
-            [],
-            '\Magento\Customer\Api\Data\CustomerInterface'
-        );
-
-        /** @var Form $customerForm */
-        $customerForm = $this->_formFactory->create(
-            \Magento\Customer\Api\CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
-            'checkout_register',
-            $customerData,
-            $this->_request->isAjax(),
-            Form::IGNORE_INVISIBLE,
-            []
-        );
-
-        if ($isCustomerNew) {
-            $customerRequest = $customerForm->prepareRequest($data);
-            $customerData = $customerForm->extractData($customerRequest);
-        }
-
-        $customerErrors = $customerForm->validateData($customerData);
-        if ($customerErrors !== true) {
-            return ['error' => -1, 'message' => implode(', ', $customerErrors)];
-        }
-
-        if (!$isCustomerNew) {
-            return true;
-        }
-
-        $customer = $this->customerDataFactory->create();
-        $this->dataObjectHelper->populateWithArray(
-            $customer,
-            $customerData,
-            '\Magento\Customer\Api\Data\CustomerInterface'
-        );
-
-        if ($quote->getCheckoutMethod() == self::METHOD_REGISTER) {
-            // We always have $customerRequest here, otherwise we would have been kicked off the function several
-            // lines above
-            $password = $customerRequest->getParam('customer_password');
-            if ($password != $customerRequest->getParam('confirm_password')) {
-                return [
-                    'error'   => -1,
-                    'message' => __('Password and password confirmation are not equal.')
-                ];
-            }
-            $quote->setPasswordHash($this->accountManagement->getPasswordHash($password));
-        } else {
-            // set NOT LOGGED IN group id explicitly,
-            // otherwise copyFieldsetToTarget('customer_account', 'to_quote') will fill it with default group id value
-            $customer->setGroupId(GroupInterface::NOT_LOGGED_IN_ID);
-        }
-
-        //validate customer
-        $result = $this->accountManagement->validate($customer);
-        if (!$result->isValid()) {
-            return [
-                'error' => -1,
-                'message' => implode(', ', $result->getMessages())
-            ];
-        }
-
-        // copy customer/guest email to address
-        $quote->getBillingAddress()->setEmail($customer->getEmail());
-
-        // copy customer data to quote
-        $this->_objectCopyService->copyFieldsetToTarget(
-            'customer_account',
-            'to_quote',
-            $this->extensibleDataObjectConverter->toFlatArray(
-                $customer,
-                [],
-                '\Magento\Customer\Api\Data\CustomerInterface'
-            ),
-            $quote
-        );
-
-        return true;
-    }
-
     /**
      * Save checkout shipping address
      *
diff --git a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php
index 0c319e19e1f377c2deea8799eb6a5e12ff461032..15275b9c11905052e18b7e4b776d2532bde7974e 100644
--- a/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Model/Type/OnepageTest.php
@@ -367,280 +367,6 @@ class OnepageTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals([], $this->onepage->saveCheckoutMethod('someMethod'));
     }
 
-    public function testSaveBillingInvalidData()
-    {
-        $this->assertEquals(['error' => -1, 'message' => 'Invalid data'], $this->onepage->saveBilling([], 0));
-    }
-
-    /**
-     * @dataProvider saveBillingDataProvider
-     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
-     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
-     * @SuppressWarnings(PHPMD.NPathComplexity)
-     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
-     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
-     */
-    public function testSaveBilling(
-        $data,
-        $customerAddressId,
-        $quoteCustomerId,
-        $addressCustomerId,
-        $isAddress,
-        $validateDataResult,
-        $validateResult,
-        $checkoutMethod,
-        $customerPassword,
-        $confirmPassword,
-        $validationResultMessages,
-        $isEmailAvailable,
-        $isVirtual,
-        $getStepDataResult,
-        $expected
-    ) {
-        $useForShipping = (int)$data['use_for_shipping'];
-
-        $passwordHash = 'password hash';
-        $this->requestMock->expects($this->any())->method('isAjax')->will($this->returnValue(false));
-        $customerValidationResultMock = $this->getMock(
-            'Magento\Customer\Api\Data\ValidationResultsInterface', [], [], '', false
-        );
-        $customerValidationResultMock
-            ->expects($this->any())
-            ->method('isValid')
-            ->will($this->returnValue(empty($validationResultMessages)));
-        $customerValidationResultMock
-            ->expects($this->any())
-            ->method('getMessages')
-            ->will($this->returnValue($validationResultMessages));
-        $this->accountManagementMock
-            ->expects($this->any())
-            ->method('getPasswordHash')
-            ->with($customerPassword)
-            ->will($this->returnValue($passwordHash));
-        $this->accountManagementMock
-            ->expects($this->any())
-            ->method('validate')
-            ->will($this->returnValue($customerValidationResultMock));
-        $this->accountManagementMock
-            ->expects($this->any())
-            ->method('isEmailAvailable')
-            ->will($this->returnValue($isEmailAvailable));
-        /** @var \Magento\Quote\Model\Quote|\PHPUnit_Framework_MockObject_MockObject $quoteMock */
-        $quoteMock = $this->getMock(
-            'Magento\Quote\Model\Quote',
-            [
-                'getData',
-                'getCustomerId',
-                '__wakeup',
-                'getBillingAddress',
-                'setPasswordHash',
-                'getCheckoutMethod',
-                'isVirtual',
-                'getShippingAddress',
-                'getCustomerData',
-                'collectTotals',
-                'save',
-                'getCustomer'
-            ],
-            [],
-            '',
-            false
-        );
-        $customerMock = $this->getMockForAbstractClass(
-            'Magento\Framework\Api\AbstractExtensibleObject',
-            [],
-            '',
-            false,
-            true,
-            true,
-            ['__toArray']
-        );
-        $shippingAddressMock = $this->getMock(
-            'Magento\Quote\Model\Quote\Address',
-            [
-                'setSameAsBilling',
-                'save',
-                'collectTotals',
-                'addData',
-                'setShippingMethod',
-                'setCollectShippingRates',
-                '__wakeup'
-            ],
-            [],
-            '',
-            false
-        );
-        $quoteMock->expects($this->any())->method('getShippingAddress')->will($this->returnValue($shippingAddressMock));
-
-        $shippingAddressMock->expects($useForShipping ? $this->any() : $this->once())
-            ->method('setSameAsBilling')
-            ->with($useForShipping)
-            ->will($this->returnSelf());
-
-        $expects = (!$useForShipping || ($checkoutMethod != Onepage::METHOD_REGISTER)) ? $this->once() : $this->never();
-        $shippingAddressMock->expects($expects)
-            ->method('save');
-
-        $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())
-            ->method('addData')
-            ->will($this->returnSelf());
-
-        $shippingAddressMock->expects($this->any())
-            ->method('setSaveInAddressBook')
-            ->will($this->returnSelf());
-
-        $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())
-            ->method('setShippingMethod')
-            ->will($this->returnSelf());
-
-        $shippingAddressMock->expects($useForShipping ? $this->once() : $this->never())
-            ->method('setCollectShippingRates')
-            ->will($this->returnSelf());
-
-        if ($useForShipping === \Magento\Checkout\Model\Type\Onepage::USE_FOR_SHIPPING) {
-            $this->totalsCollectorMock
-                ->expects($this->once())
-                ->method('collectAddressTotals')
-                ->with($quoteMock, $shippingAddressMock);
-        } else {
-            $this->totalsCollectorMock
-                ->expects($this->never())
-                ->method('collectAddressTotals')
-                ->with($quoteMock, $shippingAddressMock);
-        }
-
-        $quoteMock->expects($this->any())->method('setPasswordHash')->with($passwordHash);
-        $quoteMock->expects($this->any())->method('getCheckoutMethod')->will($this->returnValue($checkoutMethod));
-        $quoteMock->expects($this->any())->method('isVirtual')->will($this->returnValue($isVirtual));
-
-        $addressMock = $this->getMock(
-            'Magento\Quote\Model\Quote\Address',
-            [
-                'setSaveInAddressBook',
-                'getData',
-                'setEmail',
-                '__wakeup',
-                'importCustomerAddressData',
-                'validate',
-                'save'
-            ],
-            [],
-            '',
-            false
-        );
-        $addressMock->expects($this->any())->method('importCustomerAddressData')->will($this->returnSelf());
-        $addressMock->expects($this->atLeastOnce())->method('validate')->will($this->returnValue($validateResult));
-        $addressMock->expects($this->any())->method('getData')->will($this->returnValue([]));
-
-        $quoteMock->expects($this->any())->method('getBillingAddress')->will($this->returnValue($addressMock));
-        $quoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue($quoteCustomerId));
-
-        $this->quoteRepositoryMock
-            ->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->once() : $this->never())
-            ->method('save')
-            ->with($quoteMock);
-
-        $addressMock->expects($checkoutMethod === Onepage::METHOD_REGISTER ? $this->never() : $this->once())
-            ->method('save');
-
-        $quoteMock->expects($this->any())->method('getCustomer')->will($this->returnValue($customerMock));
-        $data1 = [];
-        $extensibleDataObjectConverterMock = $this->getMock(
-            'Magento\Framework\Api\ExtensibleDataObjectConverter',
-            ['toFlatArray'],
-            [],
-            '',
-            false
-        );
-        $extensibleDataObjectConverterMock->expects($this->any())
-            ->method('toFlatArray')
-            ->with($customerMock)
-            ->will($this->returnValue($data1));
-
-        $formMock = $this->getMock('Magento\Customer\Model\Metadata\Form', [], [], '', false);
-        $formMock->expects($this->atLeastOnce())->method('validateData')->will($this->returnValue($validateDataResult));
-
-        $this->formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($formMock));
-        $formMock->expects($this->any())->method('prepareRequest')->will($this->returnValue($this->requestMock));
-        $formMock->expects($this->any())
-            ->method('extractData')
-            ->with($this->requestMock)
-            ->will($this->returnValue([]));
-        $formMock->expects($this->any())
-            ->method('validateData')
-            ->with([])
-            ->will($this->returnValue(false));
-
-        $customerDataMock = $this->getMock('Magento\Customer\Api\Data\CustomerInterface', [], [], '', false);
-
-        $this->customerDataFactoryMock
-            ->expects($this->any())
-            ->method('create')
-            ->will($this->returnValue($customerDataMock));
-
-        $this->checkoutSessionMock->expects($this->any())->method('getQuote')->will($this->returnValue($quoteMock));
-        $this->checkoutSessionMock->expects($this->any())
-            ->method('getStepData')
-            ->will($this->returnValue($useForShipping ? true : $getStepDataResult));
-        $this->checkoutSessionMock->expects($this->any())->method('setStepData')->will($this->returnSelf());
-        $customerAddressMock = $this->getMockForAbstractClass(
-            'Magento\Customer\Api\Data\AddressInterface',
-            [],
-            '',
-            false
-        );
-        $customerAddressMock->expects($this->any())
-            ->method('getCustomerId')
-            ->will($this->returnValue($addressCustomerId));
-        $this->addressRepositoryMock->expects($this->any())
-            ->method('getById')
-            ->will($isAddress ? $this->returnValue($customerAddressMock) : $this->throwException(new \Exception()));
-
-        $websiteMock = $this->getMock('Magento\Store\Model\Website', [], [], '', false);
-        $this->storeManagerMock->expects($this->any())->method('getWebsite')->will($this->returnValue($websiteMock));
-        $this->assertEquals($expected, $this->onepage->saveBilling($data, $customerAddressId));
-    }
-
-    public function saveBillingDataProvider()
-    {
-        return [
-            [
-                ['use_for_shipping' => 0], // $data
-                1, // $customerAddressId
-                1, // $quoteCustomerId
-                1, // $addressCustomerId
-                true, //$isAddress
-                true, // $validateDataResult
-                true, // $validateResult
-                Onepage::METHOD_REGISTER, // $checkoutMethod
-                'password', // $customerPassword
-                'password', // $confirmPassword
-                [], // $validationResultMessages
-                true, // $isEmailAvailable
-                false, // $isVirtual
-                false, // $getStepDataResult
-                [], // $expected
-            ],
-            [
-                ['use_for_shipping' => 1], // $data
-                1, // $customerAddressId
-                1, // $quoteCustomerId
-                1, // $addressCustomerId
-                true, //$isAddress
-                true, // $validateDataResult
-                true, // $validateResult
-                Onepage::METHOD_CUSTOMER, // $checkoutMethod
-                'password', // $customerPassword
-                'password', // $confirmPassword
-                [], // $validationResultMessages
-                true, // $isEmailAvailable
-                false, // $isVirtual
-                false, // $getStepDataResult
-                [], // $expected
-            ]
-        ];
-    }
-
     public function testGetLastOrderId()
     {
         $orderIncrementId = 100001;
diff --git a/app/code/Magento/Customer/Controller/Address/FormPost.php b/app/code/Magento/Customer/Controller/Address/FormPost.php
index a3275491f6c3e4056659cbb96ded6bf7541bbd31..9360ca0f7d6d369f589a534a1cba0bd7ca489270 100644
--- a/app/code/Magento/Customer/Controller/Address/FormPost.php
+++ b/app/code/Magento/Customer/Controller/Address/FormPost.php
@@ -106,7 +106,6 @@ class FormPost extends \Magento\Customer\Controller\Address
             array_merge($existingAddressData, $attributeValues),
             '\Magento\Customer\Api\Data\AddressInterface'
         );
-
         $addressDataObject->setCustomerId($this->_getSession()->getCustomerId())
             ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
             ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
@@ -118,12 +117,16 @@ class FormPost extends \Magento\Customer\Controller\Address
      * Retrieve existing address data
      *
      * @return array
+     * @throws \Exception
      */
     protected function getExistingAddressData()
     {
         $existingAddressData = [];
         if ($addressId = $this->getRequest()->getParam('id')) {
             $existingAddress = $this->_addressRepository->getById($addressId);
+            if ($existingAddress->getCustomerId() !== $this->_getSession()->getCustomerId()) {
+                throw new \Exception();
+            }
             $existingAddressData = $this->_dataProcessor->buildOutputDataArray(
                 $existingAddress,
                 '\Magento\Customer\Api\Data\AddressInterface'
@@ -175,6 +178,7 @@ class FormPost extends \Magento\Customer\Controller\Address
      */
     public function execute()
     {
+        $redirectUrl = null;
         if (!$this->_formKeyValidator->validate($this->getRequest())) {
             return $this->resultRedirectFactory->create()->setPath('*/*/');
         }
@@ -198,11 +202,16 @@ class FormPost extends \Magento\Customer\Controller\Address
                 $this->messageManager->addError($error->getMessage());
             }
         } catch (\Exception $e) {
+            $redirectUrl = $this->_buildUrl('*/*/index');
             $this->messageManager->addException($e, __('We can\'t save the address.'));
         }
 
-        $this->_getSession()->setAddressFormData($this->getRequest()->getPostValue());
-        $url = $this->_buildUrl('*/*/edit', ['id' => $this->getRequest()->getParam('id')]);
+        $url = $redirectUrl;
+        if (!$redirectUrl) {
+            $this->_getSession()->setAddressFormData($this->getRequest()->getPostValue());
+            $url = $this->_buildUrl('*/*/edit', ['id' => $this->getRequest()->getParam('id')]);
+        }
+
         return $this->resultRedirectFactory->create()->setUrl($this->_redirect->error($url));
     }
 }
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php
index b20ff74c9039ffb4a623a9e2c2931f50a9d7eb41..f1f638a852e2e21d213cd0bb6a89b49f69a7695a 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/Validate.php
@@ -1,40 +1,45 @@
 <?php
 /**
- *
- * Copyright © 2015 Magento. All rights reserved.
+ * * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
 namespace Magento\Customer\Controller\Adminhtml\System\Config\Validatevat;
 
+use Magento\Framework\Controller\Result\JsonFactory;
+
 class Validate extends \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat
 {
     /**
-     * @var \Magento\Framework\Controller\Result\RawFactory
+     * @var JsonFactory
      */
-    protected $resultRawFactory;
+    protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
+     * @param JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
+        JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
-        $this->resultRawFactory = $resultRawFactory;
+        $this->resultJsonFactory = $resultJsonFactory;
     }
 
     /**
      * Check whether vat is valid
      *
-     * @return \Magento\Framework\Controller\Result\Raw
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
         $result = $this->_validate();
-        /** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
-        $resultRaw = $this->resultRawFactory->create();
-        return $resultRaw->setContents((int)$result->getIsValid());
+
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
+        $resultJson = $this->resultJsonFactory->create();
+        return $resultJson->setData([
+            'valid' => (int)$result->getIsValid(),
+            'message' => $result->getRequestMessage(),
+        ]);
     }
 }
diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php
index 53cd1bcc12a9af2777b734a6af62f65bce1c50af..4516a33962aeaf0dc49c9494185833f9b70da240 100644
--- a/app/code/Magento/Customer/Model/Customer.php
+++ b/app/code/Magento/Customer/Model/Customer.php
@@ -22,7 +22,7 @@ use Magento\Framework\Indexer\StateInterface;
  * Customer model
  *
  * @method int getWebsiteId() getWebsiteId()
- * @method Customer setWebsiteId(int)
+ * @method Customer setWebsiteId($value)
  * @method int getStoreId() getStoreId()
  * @method string getEmail() getEmail()
  * @method ResourceCustomer _getResource()
diff --git a/app/code/Magento/Customer/Model/Vat.php b/app/code/Magento/Customer/Model/Vat.php
index 78fd927507f72990fd8d637d5cbe7de8ac7891de..43c883b5d0e6947b4a94ef95f1d55a3a1273d19c 100644
--- a/app/code/Magento/Customer/Model/Vat.php
+++ b/app/code/Magento/Customer/Model/Vat.php
@@ -166,7 +166,8 @@ class Vat
             'is_valid' => false,
             'request_date' => '',
             'request_identifier' => '',
-            'request_success' => false
+            'request_success' => false,
+            'request_message' => __('Error during VAT Number verification.'),
         ]);
 
         if (!extension_loaded('soap')) {
@@ -194,6 +195,12 @@ class Vat
             $gatewayResponse->setRequestDate((string)$result->requestDate);
             $gatewayResponse->setRequestIdentifier((string)$result->requestIdentifier);
             $gatewayResponse->setRequestSuccess(true);
+
+            if ($gatewayResponse->getIsValid()) {
+                $gatewayResponse->setRequestMessage(__('VAT Number is valid.'));
+            } else {
+                $gatewayResponse->setRequestMessage(__('Please enter a valid VAT number.'));
+            }
         } catch (\Exception $exception) {
             $gatewayResponse->setIsValid(false);
             $gatewayResponse->setRequestDate('');
diff --git a/app/code/Magento/Customer/Setup/UpgradeData.php b/app/code/Magento/Customer/Setup/UpgradeData.php
index 7f43ee046bdd2afe812cc15260a87976a8013047..1f4da520fd0b28394e89e32e1a5cf04a4cfd580e 100644
--- a/app/code/Magento/Customer/Setup/UpgradeData.php
+++ b/app/code/Magento/Customer/Setup/UpgradeData.php
@@ -286,6 +286,13 @@ class UpgradeData implements UpgradeDataInterface
             );
         }
 
+        if (version_compare($context->getVersion(), '2.0.6', '<')) {
+            $setup->getConnection()->delete(
+                $setup->getTable('customer_form_attribute'),
+                ['form_code = ?' => 'checkout_register']
+            );
+        }
+
         $indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
         $indexer->reindexAll();
         $this->eavConfig->clear();
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php
index 3b351f5160cb0a7cdf58cf86f47438887b94afa4..39fa2018cff7a821bf4fbfa42055ed74aec74986 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Address/FormPostTest.php
@@ -528,7 +528,10 @@ class FormPostTest extends \PHPUnit_Framework_TestCase
                 ],
             ]);
 
-        $this->session->expects($this->once())
+        $this->session->expects($this->atLeastOnce())
+            ->method('getCustomerId')
+            ->willReturn($customerId);
+        $this->addressData->expects($this->once())
             ->method('getCustomerId')
             ->willReturn($customerId);
 
@@ -682,11 +685,11 @@ class FormPostTest extends \PHPUnit_Framework_TestCase
         $this->request->expects($this->once())
             ->method('isPost')
             ->willReturn(true);
-        $this->request->expects($this->exactly(2))
+        $this->request->expects($this->once())
             ->method('getParam')
             ->with('id')
             ->willReturn($addressId);
-        $this->request->expects($this->once())
+        $this->request->expects($this->never())
             ->method('getPostValue')
             ->willReturn($postValue);
 
@@ -701,7 +704,7 @@ class FormPostTest extends \PHPUnit_Framework_TestCase
             ->with($exception, __('We can\'t save the address.'))
             ->willReturnSelf();
 
-        $this->session->expects($this->once())
+        $this->session->expects($this->never())
             ->method('setAddressFormData')
             ->with($postValue)
             ->willReturnSelf();
@@ -710,7 +713,7 @@ class FormPostTest extends \PHPUnit_Framework_TestCase
             ->getMockForAbstractClass();
         $urlBuilder->expects($this->once())
             ->method('getUrl')
-            ->with('*/*/edit', ['id' => $addressId])
+            ->with('*/*/index')
             ->willReturn($url);
 
         $this->objectManager->expects($this->once())
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..ac5625eadef26d993703ae10a3a29d25d43653ec
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/System/Config/Validatevat/ValidateTest.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Customer\Test\Unit\Controller\Adminhtml\System\Config\Validatevat;
+
+class ValidateTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate
+     */
+    protected $controller;
+
+    /**
+     * @var \Magento\Backend\App\Action\Context
+     */
+    protected $context;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\Json | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resultJson;
+
+    /**
+     * @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $objectManager;
+
+    /**
+     * @var \Magento\Framework\App\Request\Http | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $request;
+
+    protected function setUp()
+    {
+        $resultJsonFactory = $this->mockResultJson();
+
+        $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->objectManager = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface')
+            ->getMockForAbstractClass();
+
+        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->context = $objectManager->getObject(
+            'Magento\Backend\App\Action\Context',
+            [
+                'request' => $this->request,
+                'objectManager' => $this->objectManager,
+            ]
+        );
+        $this->controller = $objectManager->getObject(
+            'Magento\Customer\Controller\Adminhtml\System\Config\Validatevat\Validate',
+            [
+                'context' => $this->context,
+                'resultJsonFactory' => $resultJsonFactory,
+            ]
+        );
+    }
+
+    public function testExecute()
+    {
+        $country = 'US';
+        $vat = '123456789';
+
+        $isValid = true;
+        $requestMessage = 'test';
+
+        $json = '{"valid":' . (int)$isValid . ',"message":"' . $requestMessage . '"}';
+
+        $gatewayResponse = new \Magento\Framework\DataObject([
+            'is_valid' => $isValid,
+            'request_message' => $requestMessage,
+        ]);
+
+        $this->request->expects($this->any())
+            ->method('getParam')
+            ->willReturnMap([
+                ['country', null, $country],
+                ['vat', null, $vat],
+            ]);
+
+        $vatMock = $this->getMockBuilder('Magento\Customer\Model\Vat')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $vatMock->expects($this->once())
+            ->method('checkVatNumber')
+            ->with($country, $vat)
+            ->willReturn($gatewayResponse);
+
+        $this->objectManager->expects($this->once())
+            ->method('get')
+            ->with('Magento\Customer\Model\Vat')
+            ->willReturn($vatMock);
+
+        $this->resultJson->expects($this->once())
+            ->method('setData')
+            ->with([
+                'valid' => $gatewayResponse->getIsValid(),
+                'message' => $gatewayResponse->getRequestMessage()
+            ])
+            ->willReturn($json);
+
+        $this->assertEquals($json, $this->controller->execute());
+    }
+
+    /**
+     * @return \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected function mockResultJson()
+    {
+        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
+            ->setMethods(['create'])
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $resultJsonFactory->expects($this->any())
+            ->method('create')
+            ->willReturn($this->resultJson);
+
+        return $resultJsonFactory;
+    }
+}
diff --git a/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml b/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml
index d9916cb30d0d24873fa52d22c669268651caab7d..208394342e1f4e3a3db8363077a020a275cbccc8 100644
--- a/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml
+++ b/app/code/Magento/Customer/view/adminhtml/templates/system/config/validatevat.phtml
@@ -27,11 +27,13 @@ require(['prototype'], function(){
         new Ajax.Request('<?php /* @escapeNotVerified */ echo $block->getAjaxUrl() ?>', {
             parameters: params,
             onSuccess: function(response) {
-                result = '<?php /* @escapeNotVerified */ echo __('Please enter a valid VAT number.') ?>';
+                var result = '<?php /* @escapeNotVerified */ echo __('Error during VAT Number verification.') ?>';
                 try {
-                    response = response.responseText;
-                    if (response == 1) {
-                        result = '<?php /* @escapeNotVerified */ echo __('VAT Number is valid.') ?>';
+                    if (response.responseText.isJSON()) {
+                        response = response.responseText.evalJSON();
+                        result = response.message;
+                    }
+                    if (response.valid == 1) {
                         validationMessage.removeClassName('hidden').addClassName('success')
                     } else {
                         validationMessage.removeClassName('hidden').addClassName('error')
diff --git a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml
index ade28198142c2e515ab19be9c1f4ad6f4a67832b..74b855e01b140d3a9f93e922c494b9e10b0be65f 100644
--- a/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml
+++ b/app/code/Magento/Customer/view/adminhtml/templates/tab/view/personal_info.phtml
@@ -7,7 +7,7 @@
 // @codingStandardsIgnoreFile
 
 /**
- * Template for block \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Status\PersonalInfo
+ * @var $block \Magento\Customer\Block\Adminhtml\Edit\Tab\View\PersonalInfo
  */
 
 $lastLoginDateAdmin = $block->getLastLoginDate();
diff --git a/app/code/Magento/CustomerImportExport/etc/import.xml b/app/code/Magento/CustomerImportExport/etc/import.xml
index 8a0fa98d2b2053c664fb771ebbf04fdefc53341a..5c625b53804b22c0ffb36eede408321c6164dabd 100644
--- a/app/code/Magento/CustomerImportExport/etc/import.xml
+++ b/app/code/Magento/CustomerImportExport/etc/import.xml
@@ -6,7 +6,7 @@
  */
 -->
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_ImportExport:etc/import.xsd">
-    <entity name="customer_composite" label="Customers" model="Magento\CustomerImportExport\Model\Import\CustomerComposite" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
+    <entity name="customer_composite" label="Customers and Addresses (single file)" model="Magento\CustomerImportExport\Model\Import\CustomerComposite" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Basic" />
     <entity name="customer" label="Customers Main File" model="Magento\CustomerImportExport\Model\Import\Customer" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
     <entity name="customer_address" label="Customer Addresses" model="Magento\CustomerImportExport\Model\Import\Address" behaviorModel="Magento\ImportExport\Model\Source\Import\Behavior\Custom" />
 </config>
diff --git a/app/code/Magento/Ui/Component/Form/Element/MultiSelect.php b/app/code/Magento/Ui/Component/Form/Element/MultiSelect.php
new file mode 100644
index 0000000000000000000000000000000000000000..93fd7f600e0f3a95032164f880a0cc46ba3b437a
--- /dev/null
+++ b/app/code/Magento/Ui/Component/Form/Element/MultiSelect.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Ui\Component\Form\Element;
+
+class MultiSelect extends Select
+{
+    const NAME = 'multiselect';
+
+    const DEFAULT_SIZE = 6;
+
+    /**
+     * @inheritDoc
+     */
+    public function prepare()
+    {
+        $config['size'] = self::DEFAULT_SIZE;
+        $this->setData('config', array_replace_recursive((array)$this->getData('config'), $config));
+        parent::prepare();
+    }
+}
diff --git a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml
index b8485998fec512fafd41dc1aa3dcf606a16b6e7e..090c3a9e277a5a1766d28d2dd804c87f44d38311 100755
--- a/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml
+++ b/app/code/Magento/Ui/view/base/ui_component/etc/definition.xml
@@ -199,7 +199,7 @@
             </item>
         </argument>
     </select>
-    <multiselect class="Magento\Ui\Component\Form\Element\Select">
+    <multiselect class="Magento\Ui\Component\Form\Element\MultiSelect">
         <argument name="data" xsi:type="array">
             <item name="template" xsi:type="string">ui/form/element/multiselect</item>
             <item name="js_config" xsi:type="array">
@@ -209,6 +209,9 @@
                     <item name="elementTmpl" xsi:type="string">ui/form/element/multiselect</item>
                 </item>
             </item>
+            <item name="config" xsi:type="array">
+                <item name="size" xsi:type="string">6</item>
+            </item>
         </argument>
     </multiselect>
     <textarea class="Magento\Ui\Component\Form\Element\Textarea">
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php
deleted file mode 100644
index 617b9c0dc522d649d9f2b11e3f3d989e249f4fe5..0000000000000000000000000000000000000000
--- a/dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php
+++ /dev/null
@@ -1,560 +0,0 @@
-<?php
-/**
- * Copyright © 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
-namespace Magento\Checkout\Model\Type;
-
-use Magento\TestFramework\Helper\Bootstrap;
-
-/**
- * @magentoDataFixture Magento/Checkout/_files/quote_with_product_and_payment.php
- * @magentoAppArea frontend
- */
-class OnepageTest extends \PHPUnit_Framework_TestCase
-{
-    /** @var \Magento\Checkout\Model\Type\Onepage */
-    protected $_model;
-
-    /** @var \Magento\Quote\Model\Quote */
-    protected $_currentQuote;
-
-    protected function setUp()
-    {
-        parent::setUp();
-        $this->_model = Bootstrap::getObjectManager()->create('Magento\Checkout\Model\Type\Onepage');
-        /** @var \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection */
-        $quoteCollection = Bootstrap::getObjectManager()->create('Magento\Quote\Model\ResourceModel\Quote\Collection');
-        /** @var \Magento\Quote\Model\Quote $quote */
-        $this->_currentQuote = $quoteCollection->getLastItem();
-        $this->_model->setQuote($this->_currentQuote);
-    }
-
-    /**
-     * @magentoAppIsolation enabled
-     * @magentoDbIsolation enabled
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     */
-    public function testSaveShippingWithCustomerId()
-    {
-        $this->_currentQuote->setCustomerId(1)->save();
-        $data = [
-            'address_id' => '',
-            'firstname' => 'Joe',
-            'lastname' => 'Black',
-            'company' => 'Lunatis',
-            'street' => ['1100 Parmer', 'ln.'],
-            'city' => 'Austin',
-            'region_id' => '57',
-            'region' => '',
-            'postcode' => '78757',
-            'country_id' => 'US',
-            'telephone' => '(512) 999-9999',
-            'fax' => '',
-            'save_in_address_book' => 1,
-        ];
-        $this->_model->saveShipping($data, 1);
-
-        $address = $this->_currentQuote->getShippingAddress();
-
-        /* Verify that data from Customer Address identified by id=1 is set */
-        $this->assertEquals('John', $address->getFirstname());
-        $this->assertEquals('Smith', $address->getLastname());
-        $this->assertEquals(['Green str, 67'], $address->getStreet());
-        $this->assertEquals('CityM', $address->getCity());
-        $this->assertEquals('Alabama', $address->getRegion());
-        $this->assertEquals(1, $address->getRegionId());
-        $this->assertEquals('75477', $address->getPostcode());
-        $this->assertEquals('US', $address->getCountryId());
-        $this->assertEquals('3468676', $address->getTelephone());
-        $this->assertEquals('customer@example.com', $address->getEmail());
-        $this->assertTrue($address->getCollectShippingRates());
-        $this->assertEquals(1, $address->getCustomerAddressId());
-    }
-
-    /**
-     * @magentoAppIsolation enabled
-     * @magentoDbIsolation enabled
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     */
-    public function testSaveShippingWithData()
-    {
-        $data = [
-            'address_id' => '',
-            'firstname' => 'Joe',
-            'lastname' => 'Black',
-            'company' => 'Lunatis',
-            'street' => ['1100 Parmer', 'ln.'],
-            'city' => 'Austin',
-            'region_id' => '57',
-            'region' => '',
-            'postcode' => '78757',
-            'country_id' => 'US',
-            'telephone' => '(512) 999-9999',
-            'save_in_address_book' => 1,
-        ];
-        $this->_model->saveShipping($data, null);
-
-        $address = $this->_currentQuote->getShippingAddress();
-
-        /* Verify that data from the form is set */
-        $this->assertEquals('Joe', $address->getFirstname());
-        $this->assertEquals('Black', $address->getLastname());
-        $this->assertEquals('Lunatis', $address->getCompany());
-        $this->assertEquals("1100 Parmer\nln.", $address->getData('street'));
-        $this->assertEquals('Austin', $address->getCity());
-        $this->assertEquals('US', $address->getCountryId());
-        $this->assertEquals('Texas', $address->getRegion());
-        $this->assertEquals('57', $address->getRegionId());
-        $this->assertEquals('78757', $address->getPostcode());
-        $this->assertEquals('(512) 999-9999', $address->getTelephone());
-        $this->assertNull($address->getCustomerAddressId());
-    }
-
-    /**
-     * @magentoAppIsolation enabled
-     */
-    public function testSaveOrder()
-    {
-        $this->markTestIncomplete('MAGETWO-31257');
-        $this->_model->saveBilling($this->_getCustomerData(), null);
-        $this->_prepareQuote($this->_getQuote());
-
-        $this->_model->saveOrder();
-
-        /** @var $order \Magento\Sales\Model\Order */
-        $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Sales\Model\Order');
-        $order->loadByIncrementId($this->_model->getLastOrderId());
-
-        $this->assertNotEmpty(
-            $this->_model->getQuote()->getShippingAddress()->getCustomerAddressId(),
-            'Quote shipping CustomerAddressId should not be empty'
-        );
-        $this->assertNotEmpty(
-            $this->_model->getQuote()->getBillingAddress()->getCustomerAddressId(),
-            'Quote billing CustomerAddressId should not be empty'
-        );
-
-        $this->assertNotEmpty(
-            $order->getShippingAddress()->getCustomerAddressId(),
-            'Order shipping CustomerAddressId should not be empty'
-        );
-        $this->assertNotEmpty(
-            $order->getBillingAddress()->getCustomerAddressId(),
-            'Order billing CustomerAddressId should not be empty'
-        );
-    }
-
-    /**
-     * @magentoAppIsolation enabled
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     */
-    public function testInitCheckoutNotLoggedIn()
-    {
-        /* The customer session must be cleared before the real test begins. Need to
-           have a customer via the data fixture to actually log out. */
-        /** @var $customerSession \Magento\Customer\Model\Session*/
-        $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session');
-        $customerSession->setCustomerId(1);
-        $customerSession->logout();
-
-        $this->_model->saveBilling($this->_getCustomerData(), null);
-        $this->_prepareQuote($this->_getQuote());
-        $this->assertTrue($this->_model->getCheckout()->getSteps()['shipping']['allow']);
-        $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']);
-        $this->_model->initCheckout();
-        $this->assertFalse($this->_model->getCheckout()->getSteps()['shipping']['allow']);
-        $this->assertFalse($this->_model->getCheckout()->getSteps()['billing']['allow']);
-        $this->assertNull($this->_model->getQuote()->getCustomer()->getEmail());
-    }
-
-    /**
-     * @magentoAppIsolation enabled
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     */
-    public function testInitCheckoutLoggedIn()
-    {
-        $this->_model->saveBilling($this->_getCustomerData(), null);
-        $this->_prepareQuote($this->_getQuote());
-        $customerIdFromFixture = 1;
-        $emailFromFixture = 'customer@example.com';
-        /** @var $customerSession \Magento\Customer\Model\Session*/
-        $customerSession = Bootstrap::getObjectManager()->create('Magento\Customer\Model\Session');
-        /** @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface */
-        $customerRepository = Bootstrap::getObjectManager()->create(
-            'Magento\Customer\Api\CustomerRepositoryInterface'
-        );
-        $customerData = $customerRepository->getById($customerIdFromFixture);
-        $customerSession->setCustomerDataObject($customerData);
-        $this->_model = Bootstrap::getObjectManager()->create(
-            'Magento\Checkout\Model\Type\Onepage',
-            ['customerSession' => $customerSession]
-        );
-        $this->assertTrue($this->_model->getCheckout()->getSteps()['shipping']['allow']);
-        $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']);
-        $this->_model->initCheckout();
-        $this->assertFalse($this->_model->getCheckout()->getSteps()['shipping']['allow']);
-        //When the user is logged in and for Step billing - allow is not reset to true
-        $this->assertTrue($this->_model->getCheckout()->getSteps()['billing']['allow']);
-        $this->assertEquals($emailFromFixture, $this->_model->getQuote()->getCustomer()->getEmail());
-    }
-
-    /**
-     * New customer, the same address should be used for shipping and billing, it should be persisted to DB.
-     *
-     * @magentoAppIsolation enabled
-     * @magentoDbIsolation enabled
-     */
-    public function testSaveBillingSameAsShipping()
-    {
-        $quote = $this->_model->getQuote();
-
-        /** Preconditions */
-        $customerData = $this->_getCustomerData();
-        $customerAddressId = false;
-        $this->assertEquals(1, $customerData['use_for_shipping'], "Precondition failed: use_for_shipping is invalid");
-        $this->assertEquals(
-            1,
-            $customerData['save_in_address_book'],
-            "Precondition failed: save_in_address_book is invalid"
-        );
-        $this->assertEmpty(
-            $quote->getBillingAddress()->getId(),
-            "Precondition failed: billing address must not be initialized."
-        );
-        $this->assertEmpty(
-            $quote->getShippingAddress()->getId(),
-            "Precondition failed: billing address must not be initialized."
-        );
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $this->assertEquals([], $result, 'Return value is invalid');
-
-        /** Ensure that quote addresses were persisted correctly */
-        $billingAddress = $quote->getBillingAddress();
-        $shippingAddress = $quote->getShippingAddress();
-
-        $quoteAddressFieldsToCheck = [
-            'quote_id' => $quote->getId(),
-            'firstname' => 'John',
-            'lastname' => 'Smith',
-            'email' => 'John.Smith@example.com',
-            'street' => '6131 Monterey Rd, Apt 1',
-            'city' => 'Los Angeles',
-            'postcode' => '90042',
-            'country_id' => 'US',
-            'region_id' => '1',
-            'region' => 'Alabama',
-            'telephone' => '(323) 255-5861',
-            'customer_id' => null,
-            'customer_address_id' => null,
-        ];
-
-        foreach ($quoteAddressFieldsToCheck as $field => $value) {
-            $this->assertEquals($value, $billingAddress->getData($field), "{$field} value is invalid");
-            $this->assertEquals($value, $shippingAddress->getData($field), "{$field} value is invalid");
-        }
-        $this->assertEquals('1', $shippingAddress->getData('same_as_billing'), "same_as_billing value is invalid");
-        $this->assertGreaterThan(0, $shippingAddress->getData('address_id'), "address_id value is invalid");
-        $this->assertGreaterThan(0, $billingAddress->getData('address_id'), "address_id value is invalid");
-        $this->assertEquals(
-            1,
-            $billingAddress->getData('save_in_address_book'),
-            "save_in_address_book value is invalid"
-        );
-        $this->assertEquals(
-            0,
-            $shippingAddress->getData('save_in_address_book'),
-            "As soon as 'same_as_billing' is set to 1, 'save_in_address_book' of shipping should be 0"
-        );
-
-        /** Ensure that customer-related data was ported to quote correctly */
-        $quoteFieldsToCheck = [
-            'customer_firstname' => 'John',
-            'customer_lastname' => 'Smith',
-            'customer_email' => 'John.Smith@example.com',
-        ];
-        foreach ($quoteFieldsToCheck as $field => $value) {
-            $this->assertEquals($value, $quote->getData($field), "{$field} value is set to quote incorrectly.");
-        }
-
-        /** Perform if checkout steps status was correctly updated in session */
-        /** @var \Magento\Checkout\Model\Session $checkoutSession */
-        $checkoutSession = Bootstrap::getObjectManager()->get('Magento\Checkout\Model\Session');
-        $this->assertTrue($checkoutSession->getStepData('billing', 'allow'), 'Billing step should be allowed.');
-        $this->assertTrue($checkoutSession->getStepData('billing', 'complete'), 'Billing step should be completed.');
-        $this->assertTrue($checkoutSession->getStepData('shipping', 'allow'), 'Shipping step should be allowed.');
-    }
-
-    /**
-     * New customer, billing address should not be used as shipping address, it should be persisted to DB.
-     *
-     * @magentoAppIsolation enabled
-     * @magentoDbIsolation enabled
-     */
-    public function testSaveBilling()
-    {
-        $quote = $this->_model->getQuote();
-
-        /** Preconditions */
-        $customerData = $this->_getCustomerData();
-        $customerData['use_for_shipping'] = 0;
-        $customerAddressId = false;
-        $this->assertEquals(
-            1,
-            $customerData['save_in_address_book'],
-            "Precondition failed: save_in_address_book is invalid"
-        );
-        $this->assertEmpty(
-            $quote->getBillingAddress()->getId(),
-            "Precondition failed: billing address must not be initialized."
-        );
-        $this->assertEmpty(
-            $quote->getShippingAddress()->getId(),
-            "Precondition failed: billing address must not be initialized."
-        );
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $this->assertEquals([], $result, 'Return value is invalid');
-
-        /** Ensure that quote addresses were persisted correctly */
-        $billingAddress = $quote->getBillingAddress();
-        $shippingAddress = $quote->getShippingAddress();
-
-        $quoteAddressFieldsToCheck = [
-            'quote_id' => $quote->getId(),
-            'firstname' => 'John',
-            'lastname' => 'Smith',
-            'email' => 'John.Smith@example.com',
-            'street' => '6131 Monterey Rd, Apt 1',
-            'city' => 'Los Angeles',
-            'postcode' => '90042',
-            'country_id' => 'US',
-            'region_id' => '1',
-            'region' => 'Alabama',
-            'telephone' => '(323) 255-5861',
-            'customer_id' => null,
-            'customer_address_id' => null,
-        ];
-
-        foreach ($quoteAddressFieldsToCheck as $field => $value) {
-            $this->assertEquals($value, $billingAddress->getData($field), "{$field} value is invalid");
-        }
-        $this->assertGreaterThan(0, $billingAddress->getData('address_id'), "address_id value is invalid");
-        $this->assertEmpty(
-            $shippingAddress->getData('firstname'),
-            "Shipping address should not be populated with billing address data when 'same_as_billing' is set to 0."
-        );
-        $this->assertEquals(
-            1,
-            $billingAddress->getData('save_in_address_book'),
-            "save_in_address_book value is invalid"
-        );
-
-        /** Ensure that customer-related data was ported to quote correctly */
-        $quoteFieldsToCheck = [
-            'customer_firstname' => 'John',
-            'customer_lastname' => 'Smith',
-            'customer_email' => 'John.Smith@example.com',
-        ];
-        foreach ($quoteFieldsToCheck as $field => $value) {
-            $this->assertEquals($value, $quote->getData($field), "{$field} value is set to quote incorrectly.");
-        }
-
-        /** Perform if checkout steps status was correctly updated in session */
-        /** @var \Magento\Checkout\Model\Session $checkoutSession */
-        $checkoutSession = Bootstrap::getObjectManager()->get('Magento\Checkout\Model\Session');
-        $this->assertTrue($checkoutSession->getStepData('billing', 'allow'), 'Billing step should be allowed.');
-        $this->assertTrue($checkoutSession->getStepData('billing', 'complete'), 'Billing step should be completed.');
-        $this->assertTrue($checkoutSession->getStepData('shipping', 'allow'), 'Shipping step should be allowed.');
-    }
-
-    /**
-     * New address, address data is invalid.
-     */
-    public function testSaveBillingValidationErrorNewAddress()
-    {
-        /** Preconditions */
-        $customerData = $this->_getCustomerData();
-        unset($customerData['firstname']);
-        $customerAddressId = false;
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $validationErrors = [
-            '"First Name" is a required value.',
-            '"First Name" length must be equal or greater than 1 characters.',
-        ];
-        $this->assertEquals(
-            ['error' => 1, 'message' => $validationErrors],
-            $result,
-            'Validation error is invalid.'
-        );
-    }
-
-    /**
-     * Existing address, address data is invalid.
-     *
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     */
-    public function testSaveBillingExistingAddressInvalidData()
-    {
-        /** Preconditions */
-        $addressIdFromFixture = 1;
-        $customerIdFromFixture = 1;
-        $customerData = $this->_getCustomerData();
-        unset($customerData['firstname']);
-        $this->_getQuote()->setCustomerId($customerIdFromFixture);
-
-        /** Execute SUT */
-        /**
-         * If customer address is available, provided customer data is not validated,
-         * that's why no error occurs when invalid data is provided
-         */
-        $result = $this->_model->saveBilling($customerData, $addressIdFromFixture);
-        $this->assertEquals([], $result, 'No errors expected.');
-    }
-
-    /**
-     * Address exists, but it does not belong to the current customer which is set to quote.
-     *
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     * @magentoDataFixture Magento/Customer/_files/customer_address.php
-     */
-    public function testSaveBillingInvalidAddressId()
-    {
-        /** Preconditions */
-        $addressIdFromFixture = 1;
-        $customerData = $this->_getCustomerData();
-        unset($customerData['firstname']);
-        /** Any ID can be used, which is not equal to ID of customer to which current address belongs. */
-        $secondCustomerId = 2;
-        $this->_getQuote()->setCustomerId($secondCustomerId);
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $addressIdFromFixture);
-        $validationErrors = 'The customer address is not valid.';
-        $this->assertEquals(
-            ['error' => 1, 'message' => $validationErrors],
-            $result,
-            'Validation error is invalid.'
-        );
-    }
-
-    /**
-     * Empty data.
-     */
-    public function testSaveBillingEmptyData()
-    {
-        /** Execute SUT */
-        $customerData = [];
-        $customerAddressId = false;
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $this->assertEquals(
-            ['error' => -1, 'message' => 'Invalid data'],
-            $result,
-            'Validation error is invalid.'
-        );
-    }
-
-    /**
-     * Address does not exist, but existing email is specified in address data.
-     *
-     * @magentoDataFixture Magento/Customer/_files/customer.php
-     */
-    public function testSaveBillingNewAddressErrorExistingEmail()
-    {
-        /** Preconditions */
-        $customerData = $this->_getCustomerData();
-        $fixtureCustomerEmail = 'customer@example.com';
-        $customerData['email'] = $fixtureCustomerEmail;
-        $customerAddressId = false;
-        $this->_getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER);
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $this->assertArrayHasKey('message', $result, 'Error message was expected to be set');
-        $this->assertStringStartsWith(
-            'This email address already belongs to a registered customer.',
-            (string)$result['message'],
-            'Validation error is invalid.'
-        );
-    }
-
-    /**
-     * New address, customer address is invalid (customer validation should fail, not address validation).
-     */
-    public function testSaveBillingInvalidCustomerData()
-    {
-        /** Preconditions */
-        $customerData = $this->_getCustomerData();
-        $customerData['email'] = 'invalidemail';
-        $this->_getQuote()->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER);
-        $customerAddressId = false;
-
-        /** Execute SUT */
-        $result = $this->_model->saveBilling($customerData, $customerAddressId);
-        $validationErrors = '"Email" is not a valid email address.';
-        $this->assertEquals(
-            ['error' => -1, 'message' => $validationErrors],
-            $result,
-            'Validation error is invalid.'
-        );
-    }
-
-    /**
-     * @return \Magento\Quote\Model\Quote
-     */
-    protected function _getQuote()
-    {
-        return $this->_currentQuote;
-    }
-
-    /**
-     * Prepare Quote
-     *
-     * @param \Magento\Quote\Model\Quote $quote
-     */
-    protected function _prepareQuote($quote)
-    {
-        /** @var $rate \Magento\Quote\Model\Quote\Address\Rate */
-        $rate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
-            'Magento\Quote\Model\Quote\Address\Rate'
-        );
-        $rate->setCode('freeshipping_freeshipping');
-        $rate->getPrice(1);
-
-        $quote->getShippingAddress()->setShippingMethod('freeshipping_freeshipping');
-        $quote->getShippingAddress()->addShippingRate($rate);
-        $quote->setCheckoutMethod(\Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER);
-    }
-
-    /**
-     * Customer data for quote
-     *
-     * @return array
-     */
-    protected function _getCustomerData()
-    {
-        return [
-            'firstname' => 'John',
-            'lastname' => 'Smith',
-            'email' => 'John.Smith@example.com',
-            'street' => ['6131 Monterey Rd, Apt 1', ''],
-            'city' => 'Los Angeles',
-            'postcode' => '90042',
-            'country_id' => 'US',
-            'region_id' => '1',
-            'telephone' => '(323) 255-5861',
-            'customer_password' => 'password',
-            'confirm_password' => 'password',
-            'save_in_address_book' => '1',
-            'use_for_shipping' => '1'
-        ];
-    }
-}