diff --git a/app/code/Magento/Checkout/Block/Cart/Shipping.php b/app/code/Magento/Checkout/Block/Cart/Shipping.php
index fd79502fbcb0d30195e19be88f619b2f7491c56c..8c8636d87d8be418d8b0f6dc884e0401700f7b3d 100644
--- a/app/code/Magento/Checkout/Block/Cart/Shipping.php
+++ b/app/code/Magento/Checkout/Block/Cart/Shipping.php
@@ -76,6 +76,11 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
      */
     protected $quoteRepository;
 
+    /**
+     * @var \Magento\Checkout\Model\Cart\CollectQuote
+     */
+    protected $collectQuote;
+
     /**
      * @param \Magento\Framework\View\Element\Template\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
@@ -88,6 +93,7 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
      * @param AddressRepositoryInterface $addressRepository
      * @param CustomerRepositoryInterface $customerRepository
      * @param QuoteRepository $quoteRepository
+     * @param \Magento\Checkout\Model\Cart\CollectQuote $collectQuote
      * @param array $data
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -103,6 +109,7 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
         AddressRepositoryInterface $addressRepository,
         CustomerRepositoryInterface $customerRepository,
         QuoteRepository $quoteRepository,
+        \Magento\Checkout\Model\Cart\CollectQuote $collectQuote,
         array $data = []
     ) {
         $this->priceCurrency = $priceCurrency;
@@ -113,12 +120,12 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
         $this->addressRepository = $addressRepository;
         $this->customerRepository = $customerRepository;
         $this->quoteRepository = $quoteRepository;
+        $this->collectQuote = $collectQuote;
         parent::__construct($context, $customerSession, $checkoutSession, $data);
         $this->_isScopePrivate = true;
     }
 
-    /**
-     * Get config
+    /** Get config
      *
      * @param string $path
      * @return string|null
@@ -364,22 +371,7 @@ class Shipping extends \Magento\Checkout\Block\Cart\AbstractCart
      */
     protected function _beforeToHtml()
     {
-        if ($this->_customerSession->isLoggedIn()) {
-            $customer = $this->customerRepository->getById($this->_customerSession->getCustomerId());
-            if ($defaultShipping = $customer->getDefaultShipping()) {
-                $address = $this->addressRepository->getById($defaultShipping);
-                if ($address) {
-                    /** @var \Magento\Quote\Api\Data\EstimateAddressInterface $estimatedAddress */
-                    $estimatedAddress = $this->estimatedAddressFactory->create();
-                    $estimatedAddress->setCountryId($address->getCountryId());
-                    $estimatedAddress->setPostcode($address->getPostcode());
-                    $estimatedAddress->setRegion((string)$address->getRegion()->getRegion());
-                    $estimatedAddress->setRegionId($address->getRegionId());
-                    $this->shippingMethodManager->estimateByAddress($this->getQuote()->getId(), $estimatedAddress);
-                    $this->quoteRepository->save($this->getQuote());
-                }
-            }
-        }
+        $this->collectQuote->collect($this->getQuote());
         return parent::_beforeToHtml();
     }
 
diff --git a/app/code/Magento/Checkout/Model/Cart/CollectQuote.php b/app/code/Magento/Checkout/Model/Cart/CollectQuote.php
new file mode 100644
index 0000000000000000000000000000000000000000..170f2e6a9cb0825fbd22053fe445eb39c9a4a602
--- /dev/null
+++ b/app/code/Magento/Checkout/Model/Cart/CollectQuote.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Checkout\Model\Cart;
+
+class CollectQuote
+{
+    /**
+     * @var \Magento\Customer\Model\Session
+     */
+    protected $customerSession;
+
+    /**
+     * @var \Magento\Customer\Api\CustomerRepositoryInterface
+     */
+    protected $customerRepository;
+
+    /**
+     * @var \Magento\Customer\Api\AddressRepositoryInterface
+     */
+    protected $addressRepository;
+
+    /**
+     * @var \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory
+     */
+    protected $estimatedAddressFactory;
+
+    /**
+     * @var \Magento\Quote\Api\ShippingMethodManagementInterface
+     */
+    protected $shippingMethodManager;
+
+    /**
+     * @var \Magento\Quote\Model\QuoteRepository
+     */
+    protected $quoteRepository;
+
+    /**
+     * @param \Magento\Customer\Model\Session $customerSession
+     * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
+     * @param \Magento\Customer\Api\AddressRepositoryInterface $addressRepository
+     * @param \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory
+     * @param \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager
+     * @param \Magento\Quote\Model\QuoteRepository $quoteRepository
+     */
+    public function __construct(
+        \Magento\Customer\Model\Session $customerSession,
+        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
+        \Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
+        \Magento\Quote\Api\Data\EstimateAddressInterfaceFactory $estimatedAddressFactory,
+        \Magento\Quote\Api\ShippingMethodManagementInterface $shippingMethodManager,
+        \Magento\Quote\Model\QuoteRepository $quoteRepository
+    ) {
+        $this->customerSession = $customerSession;
+        $this->customerRepository = $customerRepository;
+        $this->addressRepository = $addressRepository;
+        $this->estimatedAddressFactory = $estimatedAddressFactory;
+        $this->shippingMethodManager = $shippingMethodManager;
+        $this->quoteRepository = $quoteRepository;
+    }
+
+    /**
+     * @param \Magento\Quote\Model\Quote $quote
+     * @return void
+     */
+    public function collect(\Magento\Quote\Model\Quote $quote)
+    {
+        if ($this->customerSession->isLoggedIn()) {
+            $customer = $this->customerRepository->getById($this->customerSession->getCustomerId());
+            if ($defaultShipping = $customer->getDefaultShipping()) {
+                $address = $this->addressRepository->getById($defaultShipping);
+                if ($address) {
+                    /** @var \Magento\Quote\Api\Data\EstimateAddressInterface $estimatedAddress */
+                    $estimatedAddress = $this->estimatedAddressFactory->create();
+                    $estimatedAddress->setCountryId($address->getCountryId());
+                    $estimatedAddress->setPostcode($address->getPostcode());
+                    $estimatedAddress->setRegion((string)$address->getRegion()->getRegion());
+                    $estimatedAddress->setRegionId($address->getRegionId());
+                    $this->shippingMethodManager->estimateByAddress($quote->getId(), $estimatedAddress);
+                    $this->quoteRepository->save($quote);
+                }
+            }
+        }
+    }
+}
diff --git a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
index 13fbfbc990be11852eef14ff41ee0bcbcc708484..eee32ec716ca518dcfe8f5636863f6641e336b21 100644
--- a/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Block/Cart/ShippingTest.php
@@ -85,6 +85,9 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
     /** @var  Quote |\PHPUnit_Framework_MockObject_MockObject */
     protected $quote;
 
+    /** @var \PHPUnit_Framework_MockObject_MockObject */
+    protected $collectQuote;
+
     protected function setUp()
     {
         $this->prepareContext();
@@ -117,8 +120,13 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
         $this->customerRepository = $this->getMockBuilder('Magento\Customer\Api\CustomerRepositoryInterface')
             ->getMockForAbstractClass();
 
+        $this->collectQuote = $this->getMockBuilder('Magento\Checkout\Model\Cart\CollectQuote')
+            ->disableOriginalConstructor()
+            ->getMock();
+
         $this->prepareQuoteRepository();
 
+
         $this->model = new Shipping(
             $this->context,
             $this->customerSession,
@@ -130,7 +138,8 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
             $this->shippingMethodManager,
             $this->addressReporitory,
             $this->customerRepository,
-            $this->quoteRepository
+            $this->quoteRepository,
+            $this->collectQuote
         );
     }
 
@@ -259,182 +268,19 @@ class ShippingTest extends \PHPUnit_Framework_TestCase
             ->with('advanced/modules_disable_output/Magento_Checkout', ScopeInterface::SCOPE_STORE)
             ->willReturn(false);
 
-        $this->customerSession->expects($this->once())
-            ->method('isLoggedIn')
-            ->willReturn(false);
-
-        $this->assertEquals('', $this->model->toHtml());
-    }
-
-    public function testBeforeToHtmlNoDefaultShippingAddress()
-    {
-        $customerId = 1;
-        $defaultShipping = 0;
-
-        $this->eventManager->expects($this->once())
-            ->method('dispatch')
-            ->with('view_block_abstract_to_html_before', ['block' => $this->model])
-            ->willReturnSelf();
-
-        $this->scopeConfig->expects($this->once())
-            ->method('getValue')
-            ->with('advanced/modules_disable_output/Magento_Checkout', ScopeInterface::SCOPE_STORE)
-            ->willReturn(false);
-
-        $this->customerSession->expects($this->once())
-            ->method('isLoggedIn')
-            ->willReturn(true);
-        $this->customerSession->expects($this->once())
-            ->method('getCustomerId')
-            ->willReturn($customerId);
-
-        $customerData = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')
-            ->setMethods([
-                'getDefaultShipping',
-            ])
-            ->getMockForAbstractClass();
-        $customerData->expects($this->once())
-            ->method('getDefaultShipping')
-            ->willReturn($defaultShipping);
-
-        $this->customerRepository->expects($this->once())
-            ->method('getById')
-            ->with($customerId)
-            ->willReturn($customerData);
-
-        $this->assertEquals('', $this->model->toHtml());
-    }
-
-    /**
-     * @param int $customerId
-     * @param int $defaultShipping
-     * @param int $countryId
-     * @param string $postcode
-     * @param string $region
-     * @param int $regionId
-     * @param int $quoteId
-     * @dataProvider dataProviderBeforeToHtml
-     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
-     */
-    public function testBeforeToHtml(
-        $customerId,
-        $defaultShipping,
-        $countryId,
-        $postcode,
-        $region,
-        $regionId,
-        $quoteId
-    ) {
-        $this->eventManager->expects($this->once())
-            ->method('dispatch')
-            ->with('view_block_abstract_to_html_before', ['block' => $this->model])
-            ->willReturnSelf();
-
-        $this->scopeConfig->expects($this->once())
-            ->method('getValue')
-            ->with('advanced/modules_disable_output/Magento_Checkout', ScopeInterface::SCOPE_STORE)
-            ->willReturn(false);
-
-        $this->customerSession->expects($this->once())
-            ->method('isLoggedIn')
-            ->willReturn(true);
-        $this->customerSession->expects($this->once())
-            ->method('getCustomerId')
-            ->willReturn($customerId);
-
-        $customerDataMock = $this->getMockBuilder('Magento\Customer\Api\Data\CustomerInterface')
-            ->setMethods([
-                'getDefaultShipping',
-            ])
-            ->getMockForAbstractClass();
-        $customerDataMock->expects($this->once())
-            ->method('getDefaultShipping')
-            ->willReturn($defaultShipping);
-
-        $this->customerRepository->expects($this->once())
-            ->method('getById')
-            ->with($customerId)
-            ->willReturn($customerDataMock);
-
-        $this->addressReporitory->expects($this->once())
-            ->method('getById')
-            ->with($defaultShipping)
-            ->willReturn($this->address);
-
-        $regionMock = $this->getMockBuilder('Magento\Customer\Api\Data\RegionInterface')
-            ->setMethods([
-                'getRegion',
-            ])
-            ->getMockForAbstractClass();
-        $regionMock->expects($this->once())
-            ->method('getRegion')
-            ->willReturn($region);
-
-        $this->address->expects($this->once())
-            ->method('getCountryId')
-            ->willReturn($countryId);
-        $this->address->expects($this->once())
-            ->method('getPostcode')
-            ->willReturn($postcode);
-        $this->address->expects($this->once())
-            ->method('getRegion')
-            ->willReturn($regionMock);
-        $this->address->expects($this->once())
-            ->method('getRegionId')
-            ->willReturn($regionId);
-
-        $this->estimatedAddress->expects($this->once())
-            ->method('setCountryId')
-            ->with($countryId)
-            ->willReturnSelf();
-        $this->estimatedAddress->expects($this->once())
-            ->method('setPostcode')
-            ->with($postcode)
-            ->willReturnSelf();
-        $this->estimatedAddress->expects($this->once())
-            ->method('setRegion')
-            ->with($region)
-            ->willReturnSelf();
-        $this->estimatedAddress->expects($this->once())
-            ->method('setRegionId')
-            ->with($regionId)
-            ->willReturnSelf();
-
-        $this->checkoutSession->expects($this->once())
+        $quote = $this->getMockBuilder('Magento\Quote\Model\Quote')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->checkoutSession->expects($this->any())
             ->method('getQuote')
-            ->willReturn($this->quote);
-
-        $this->quote->expects($this->once())
-            ->method('getId')
-            ->willReturn($quoteId);
-
-        $this->shippingMethodManager->expects($this->once())
-            ->method('estimateByAddress')
-            ->with($quoteId, $this->estimatedAddress)
-            ->willReturnSelf();
-
-        $this->quoteRepository->expects($this->once())
-            ->method('save')
-            ->with($this->quote)
-            ->willReturnSelf();
+            ->willReturn($quote);
+        $this->collectQuote->expects($this->once())
+            ->method('collect')
+            ->with($quote);
 
         $this->assertEquals('', $this->model->toHtml());
     }
 
-    /**
-     * @return array
-     */
-    public function dataProviderBeforeToHtml()
-    {
-        return [
-            [1, 1, 1, '12345', '', 1, 1],
-            [1, 1, 1, '12345', '', 0, 1],
-            [1, 1, 1, '', '', 0, 1],
-            [1, 1, 1, '12345', 'California', 0, 1],
-            [1, 1, 1, '12345', 'California', 1, 1],
-        ];
-    }
-
     /**
      * @param int $count
      * @param bool $expectedResult
diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
index a02d5af3c3916da9bea09c5aef080cce4f38c648..b67361c4fcc8a740dddceeadaed4fe4b4e3429a5 100644
--- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
@@ -187,8 +187,9 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
                     'amount' => $this->_registerJsPrice($this->_convertPrice($regularPrice->getAmount()->getValue())),
                 ],
                 'basePrice' => [
-                    'amount' =>
-                        $this->_registerJsPrice($this->_convertPrice($finalPrice->getAmount()->getBaseAmount())),
+                    'amount' => $this->_registerJsPrice(
+                        $this->_convertPrice($finalPrice->getAmount()->getBaseAmount())
+                    ),
                 ],
                 'finalPrice' => [
                     'amount' => $this->_registerJsPrice($this->_convertPrice($finalPrice->getAmount()->getValue())),
@@ -197,7 +198,6 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
             'productId' => $currentProduct->getId(),
             'chooseText' => __('Choose an Option...'),
             'images' => isset($options['images']) ? $options['images'] : [],
-            'baseImage' => $options['baseImage'],
         ];
 
         if ($currentProduct->hasPreconfiguredValues() && !empty($attributesData['defaultValues'])) {
diff --git a/app/code/Magento/ConfigurableProduct/Helper/Data.php b/app/code/Magento/ConfigurableProduct/Helper/Data.php
index ed0c999f3761ec267791a2f79336965107d0b743..0a30e2f5a5c8d2398b928463cbad080d9148851b 100644
--- a/app/code/Magento/ConfigurableProduct/Helper/Data.php
+++ b/app/code/Magento/ConfigurableProduct/Helper/Data.php
@@ -58,7 +58,6 @@ class Data
                 $options['images'][$productAttributeId][$attributeValue][$productId] = $imageUrl;
             }
         }
-        $options['baseImage'] = $baseImageUrl;
 
         return $options;
     }
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php
index 4d2d219bc2258d8a5af681f5e8ab4512cce0964f..031dac827c83563ccc7dbd5fcd2d9d9bf29d9cba 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Helper/DataTest.php
@@ -82,11 +82,10 @@ class DataTest extends \PHPUnit_Framework_TestCase
         );
         $provider = [];
         $provider[] = [
-            ['baseImage' => 'http://example.com/base_img_url'],
+            [],
             [
                 'allowed_products' => [],
                 'current_product_mock' => $currentProductMock,
-                'baseImage' => 'http://example.com/base_img_url'
             ],
         ];
 
@@ -163,12 +162,10 @@ class DataTest extends \PHPUnit_Framework_TestCase
                 'attribute_id_2' => [
                     'attribute_code_value_2' => ['product_id_1', 'product_id_2'],
                 ],
-                'baseImage' => 'http://example.com/base_img_url',
             ],
             [
                 'allowed_products' => $allowedProducts,
                 'current_product_mock' => $currentProductMock,
-                'baseImage' => 'http://example.com/base_img_url'
             ],
         ];
         return $provider;
diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
index 0b1449f2bc2733d3c7ebb006e0a66887bc51d360..34cbd39eff804f1bf15ced403f4acf96b0563c0a 100644
--- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
+++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
@@ -10,7 +10,8 @@ define([
     "priceUtils",
     "priceBox",
     "jquery/ui",
-    "jquery/jquery.parsequery"
+    "jquery/jquery.parsequery",
+    "mage/gallery"
 ], function($, _, mageTemplate, utils){
 
     $.widget('mage.configurable', {
@@ -69,6 +70,10 @@ define([
 
             this.options.values = this.options.spConfig.defaultValues || {};
             this.options.parentImage = $('[data-role=base-image-container] img').attr('src');
+
+            this.initialGalleryImages = $(this.options.mediaGallerySelector).data('mageGallery')
+                ? $(this.options.mediaGallerySelector).gallery('option', 'images')
+                : [];
             this.inputSimpleProduct = this.element.find(this.options.selectSimpleProduct);
         },
 
@@ -226,12 +231,7 @@ define([
         _changeProductImage: function () {
             var images = this.options.spConfig.images,
                 imagesArray = null,
-                galleryElement = $(this.options.mediaGallerySelector),
-                baseImage = {
-                    small: this.options.spConfig.baseImage,
-                    medium: this.options.spConfig.baseImage,
-                    large: this.options.spConfig.baseImage
-                };
+                galleryElement = $(this.options.mediaGallerySelector);
             $.each(this.options.settings, function (k, v) {
                 var selectValue = parseInt(v.value, 10),
                     attributeId = v.id.replace(/[a-z]*/, '');
@@ -251,18 +251,16 @@ define([
             });
 
             var result = [];
-            $.each(imagesArray || baseImage, function (k, v) {
+            $.each(imagesArray || {}, function (k, v) {
                 result.push({
                     small: v,
                     medium: v,
                     large: v
                 });
             });
-            if (result.length !== 1) {
-                result = [baseImage];
-            }
+
             if (galleryElement.length && galleryElement.data('mageGallery')) {
-                galleryElement.gallery('option', 'images', result);
+                galleryElement.gallery('option', 'images', result.length > 0 ? result : this.initialGalleryImages);
             }
         },
 
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php
index ca83df2fe053b89ad6e244f541cfb74443757406..f3b8531f03bb63da928fad392e9a8983043cb509 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Grid.php
@@ -12,51 +12,4 @@ namespace Magento\Sales\Block\Adminhtml\Order;
  */
 class Grid extends \Magento\Backend\Block\Widget\Grid
 {
-    /**
-     * @var \Magento\Framework\View\Element\UiComponentFactory
-     */
-    protected $componentFactory;
-
-    /**
-     * @param \Magento\Backend\Block\Template\Context $context
-     * @param \Magento\Backend\Helper\Data $backendHelper
-     * @param \Magento\Framework\View\Element\UiComponentFactory $componentFactory
-     * @param array $data
-     */
-    public function __construct(
-        \Magento\Backend\Block\Template\Context $context,
-        \Magento\Backend\Helper\Data $backendHelper,
-        \Magento\Framework\View\Element\UiComponentFactory $componentFactory,
-        array $data = []
-    ) {
-        $this->componentFactory = $componentFactory;
-        parent::__construct($context, $backendHelper, $data);
-    }
-
-    /**
-     * @return $this
-     * @throws \Magento\Framework\Exception\LocalizedException
-     */
-    protected function _prepareCollection()
-    {
-        $component = $this->componentFactory->create('sales_order_grid');
-        $this->prepareComponent($component);
-        $component->render();
-        $collection = $component->getContext()->getDataProvider()->getCollection();
-        $this->setData('dataSource', $collection);
-
-        return parent::_prepareCollection();
-    }
-
-    /**
-     * @param \Magento\Framework\View\Element\UiComponentInterface $componentElement
-     * @return void
-     */
-    protected function prepareComponent(\Magento\Framework\View\Element\UiComponentInterface $componentElement)
-    {
-        foreach ($componentElement->getChildComponents() as $childComponent) {
-            $this->prepareComponent($childComponent);
-        }
-        $componentElement->prepare();
-    }
 }
diff --git a/app/code/Magento/Sales/Controller/AbstractController/OrderLoader.php b/app/code/Magento/Sales/Controller/AbstractController/OrderLoader.php
index 567433355f3ed1a97c2959c2b2c5088e285a6e33..cb24f26d365d5cacd076b16212d432f63e8ef0a7 100644
--- a/app/code/Magento/Sales/Controller/AbstractController/OrderLoader.php
+++ b/app/code/Magento/Sales/Controller/AbstractController/OrderLoader.php
@@ -9,6 +9,7 @@ namespace Magento\Sales\Controller\AbstractController;
 use Magento\Framework\App\RequestInterface;
 use Magento\Framework\Registry;
 use Magento\Framework\Controller\Result\ForwardFactory;
+use Magento\Framework\Controller\Result\RedirectFactory;
 
 class OrderLoader implements OrderLoaderInterface
 {
@@ -37,25 +38,33 @@ class OrderLoader implements OrderLoaderInterface
      */
     protected $resultForwardFactory;
 
+    /**
+     * @var RedirectFactory
+     */
+    protected $redirectFactory;
+
     /**
      * @param \Magento\Sales\Model\OrderFactory $orderFactory
      * @param OrderViewAuthorizationInterface $orderAuthorization
      * @param Registry $registry
      * @param \Magento\Framework\UrlInterface $url
      * @param ForwardFactory $resultForwardFactory
+     * @param RedirectFactory $redirectFactory
      */
     public function __construct(
         \Magento\Sales\Model\OrderFactory $orderFactory,
         OrderViewAuthorizationInterface $orderAuthorization,
         Registry $registry,
         \Magento\Framework\UrlInterface $url,
-        ForwardFactory $resultForwardFactory
+        ForwardFactory $resultForwardFactory,
+        RedirectFactory $redirectFactory
     ) {
         $this->orderFactory = $orderFactory;
         $this->orderAuthorization = $orderAuthorization;
         $this->registry = $registry;
         $this->url = $url;
         $this->resultForwardFactory = $resultForwardFactory;
+        $this->redirectFactory = $redirectFactory;
     }
 
     /**
@@ -78,7 +87,7 @@ class OrderLoader implements OrderLoaderInterface
             return true;
         }
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
-        $resultRedirect = $this->resultRedirectFactory->create();
+        $resultRedirect = $this->redirectFactory->create();
         return $resultRedirect->setUrl($this->url->getUrl('*/*/history'));
     }
 }
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
index fdc6bdcbdabf51de424178ee5b21995740be0533..fe4f2aeb163b674aa5c8ca27c58cd8625402bc67 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/AbstractMassAction.php
@@ -21,7 +21,7 @@ abstract class AbstractMassAction extends \Magento\Backend\App\Action
     /**
      * Redirect url
      */
-    const REDIRECT_URL = '*/*/';
+    const REDIRECT_URL = 'sales/order/';
 
     /**
      * Resource collection
diff --git a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
index 53afa0147c7756ac9cd388da9d4406da6c1efa74..33e1dbc2278167926970e7b5b3760320db16be0c 100644
--- a/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
+++ b/app/code/Magento/Sales/Model/Resource/AbstractGrid.php
@@ -57,6 +57,15 @@ abstract class AbstractGrid extends AbstractDb implements GridInterface
         return $this->connection;
     }
 
+    /**
+     * Returns grid table name
+     *
+     * @return string
+     */
+    public function getGridTable()
+    {
+        return $this->getTable($this->gridTableName);
+    }
     /**
      * Purge grid row
      *
diff --git a/app/code/Magento/Sales/Model/Resource/Order.php b/app/code/Magento/Sales/Model/Resource/Order.php
index f44ca611da317a9068111add4782c16dec481591..7aa6ec68f8232a594f4a0c2bde261c9a60b9acc6 100644
--- a/app/code/Magento/Sales/Model/Resource/Order.php
+++ b/app/code/Magento/Sales/Model/Resource/Order.php
@@ -126,7 +126,9 @@ class Order extends SalesResource implements OrderResourceInterface
                 $parent = $item->getQuoteParentItemId();
                 if ($parent && !$item->getParentItem()) {
                     $item->setParentItem($object->getItemByQuoteItemId($parent));
-                } elseif (!$parent) {
+                }
+                $childItems = $item->getChildrenItems();
+                if (empty($childItems)) {
                     $itemsCount++;
                 }
             }
diff --git a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php
index 98ba820ade67fd143dabb1215e1462ad9ff59cce..2a3ddf1b44011c8c460571ffc4e7732a2cab3d92 100644
--- a/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Block/Adminhtml/Order/GridTest.php
@@ -11,11 +11,6 @@ namespace Magento\Sales\Test\Unit\Block\Adminhtml\Order;
  */
 class GridTest extends \PHPUnit_Framework_TestCase
 {
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $componentFactory;
-
     /**
      * @var \Magento\Sales\Block\Adminhtml\Order\Grid
      */
@@ -33,9 +28,6 @@ class GridTest extends \PHPUnit_Framework_TestCase
 
     protected function setUp()
     {
-        $this->componentFactory = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentFactory')
-            ->disableOriginalConstructor()
-            ->getMock();
         $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
             ->disableOriginalConstructor()
             ->setMethods(['has'])
@@ -47,7 +39,6 @@ class GridTest extends \PHPUnit_Framework_TestCase
             ->method('getRequest')
             ->willReturn($this->requestMock);
         $arguments = [
-            'componentFactory' => $this->componentFactory,
             'context' => $this->contextMock
         ];
         $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -57,45 +48,9 @@ class GridTest extends \PHPUnit_Framework_TestCase
 
     public function testPrepareCollection()
     {
-        $contextMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponent\ContextInterface')
-            ->disableOriginalConstructor()
-            ->getMock();
         $collectionMock = $this->getMockBuilder('Magento\Sales\Model\Resource\Order\Grid\Collection')
             ->disableOriginalConstructor()
             ->getMock();
-        $providerName = 'Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider';
-        $dataProviderMock = $this->getMockBuilder($providerName)
-            ->disableOriginalConstructor()
-            ->getMock();
-        $componentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $childComponentMock = $this->getMockBuilder('Magento\Framework\View\Element\UiComponentInterface')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $this->componentFactory->expects($this->once())
-            ->method('create')
-            ->with('sales_order_grid')
-            ->willReturn($componentMock);
-        $componentMock->expects($this->once())
-            ->method('getChildComponents')
-            ->willReturn([$childComponentMock]);
-        $childComponentMock->expects($this->once())
-            ->method('getChildComponents')
-            ->willReturn([]);
-        $childComponentMock->expects($this->once())
-            ->method('prepare');
-        $componentMock->expects($this->once())
-            ->method('render');
-        $componentMock->expects($this->once())
-            ->method('getContext')
-            ->willReturn($contextMock);
-        $contextMock->expects($this->once())
-            ->method('getDataProvider')
-            ->willReturn($dataProviderMock);
-        $dataProviderMock->expects($this->once())
-            ->method('getCollection')
-            ->willReturn($collectionMock);
         $this->requestMock->expects($this->any())
             ->method('has')
             ->withAnyParameters()
@@ -120,9 +75,7 @@ class GridTest extends \PHPUnit_Framework_TestCase
             ->willReturn($blockMock);
         $this->block->setData('id', 1);
         $this->block->setLayout($layoutMock);
-        $this->assertInstanceOf(
-            'Magento\Sales\Model\Resource\Order\Grid\Collection',
-            $this->block->getPreparedCollection()
-        );
+        $this->block->setCollection($collectionMock);
+        $this->assertEquals($collectionMock, $this->block->getPreparedCollection());
     }
 }
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php
index 0c64b01b99d7822b5e0dd5db92bb5bb52b3cc170..ce8fe0cf97dd036e93447e51b665d6d473d2d7c4 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/InvoiceTest.php
@@ -8,6 +8,7 @@
 
 namespace Magento\Sales\Test\Unit\Model\Order;
 
+use Magento\Sales\Model\Order\Invoice;
 use Magento\Sales\Model\Resource\OrderFactory;
 
 /**
@@ -22,6 +23,17 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
      */
     protected $model;
 
+    /**
+     * Same as $model but Order was not set
+     * @var \Magento\Sales\Model\Order\Invoice
+     */
+    protected $modelWithoutOrder;
+
+    /**
+     * @var string
+     */
+    protected $entityType = 'invoice';
+
     /**
      * @var OrderFactory |\PHPUnit_Framework_MockObject_MockObject
      */
@@ -35,25 +47,50 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Sales\Model\Order\Payment
      */
-    protected $_paymentMock;
+    protected $paymentMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Event\ManagerInterface
+     */
+    protected $eventManagerMock;
+
+    /**
+     * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+     */
+    protected $helperManager;
 
     protected function setUp()
     {
-        $helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->helperManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
         $this->orderMock = $this->getMockBuilder(
             'Magento\Sales\Model\Order'
         )->disableOriginalConstructor()->setMethods(
-            ['getPayment', '__wakeup', 'load', 'setHistoryEntityName']
+            [
+                'getPayment', '__wakeup', 'load', 'setHistoryEntityName', 'getStore', 'getBillingAddress',
+                'getShippingAddress'
+            ]
         )->getMock();
-        $this->_paymentMock = $this->getMockBuilder(
+        $this->orderMock->expects($this->any())
+            ->method('setHistoryEntityName')
+            ->with($this->entityType)
+            ->will($this->returnSelf());
+
+        $this->paymentMock = $this->getMockBuilder(
             'Magento\Sales\Model\Order\Payment'
         )->disableOriginalConstructor()->setMethods(
-            ['canVoid', '__wakeup']
+            ['canVoid', '__wakeup', 'canCapture', 'capture', 'pay', 'hasForcedState', 'getForcedState']
         )->getMock();
 
         $this->orderFactory = $this->getMock('Magento\Sales\Model\OrderFactory', ['create'], [], '', false);
 
+        $this->eventManagerMock = $this->getMock('\Magento\Framework\Event\ManagerInterface', [], [], '', false);
+        $contextMock = $this->getMock('\Magento\Framework\Model\Context', [], [], '', false);
+        $contextMock->expects($this->any())
+            ->method('getEventDispatcher')
+            ->willReturn($this->eventManagerMock);
+
         $arguments = [
+            'context' => $contextMock,
             'orderFactory' => $this->orderFactory,
             'orderResourceFactory' => $this->getMock(
                 'Magento\Sales\Model\Resource\OrderFactory',
@@ -91,8 +128,9 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
                 false
             ),
         ];
-        $this->model = $helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments);
+        $this->model = $this->helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments);
         $this->model->setOrder($this->orderMock);
+        $this->modelWithoutOrder = $this->helperManager->getObject('Magento\Sales\Model\Order\Invoice', $arguments);
     }
 
     /**
@@ -101,20 +139,10 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
      */
     public function testCanVoid($canVoid)
     {
-        $entityName = 'invoice';
-        $this->orderMock->expects($this->once())->method('getPayment')->will($this->returnValue($this->_paymentMock));
-        $this->orderMock->expects($this->once())
-            ->method('setHistoryEntityName')
-            ->with($entityName)
-            ->will($this->returnSelf());
-        $this->_paymentMock->expects(
-            $this->once()
-        )->method(
-            'canVoid',
-            '__wakeup'
-        )->will(
-            $this->returnValue($canVoid)
-        );
+        $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
+        $this->paymentMock->expects($this->once())
+            ->method('canVoid', '__wakeup')
+            ->willReturn($canVoid);
 
         $this->model->setState(\Magento\Sales\Model\Order\Invoice::STATE_PAID);
         $this->assertEquals($canVoid, $this->model->canVoid());
@@ -139,20 +167,36 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
 
     public function testGetOrder()
     {
-        $orderId = 100000041;
-        $this->model->setOrderId($orderId);
-        $entityName = 'invoice';
-        $this->orderMock->expects($this->atLeastOnce())
+        $this->orderMock->expects($this->once())
             ->method('setHistoryEntityName')
-            ->with($entityName)
+            ->with($this->entityType)
             ->will($this->returnSelf());
 
         $this->assertEquals($this->orderMock, $this->model->getOrder());
     }
 
+    public function testGetOrderLoadedById()
+    {
+        $orderId = 100000041;
+        $this->modelWithoutOrder->setOrderId($orderId);
+        $this->orderMock->expects($this->once())
+            ->method('load')
+            ->with($orderId)
+            ->willReturnSelf();
+        $this->orderMock->expects($this->once())
+            ->method('setHistoryEntityName')
+            ->with($this->entityType)
+            ->willReturnSelf();
+        $this->orderFactory->expects($this->once())
+            ->method('create')
+            ->willReturn($this->orderMock);
+
+        $this->assertEquals($this->orderMock, $this->modelWithoutOrder->getOrder());
+    }
+
     public function testGetEntityType()
     {
-        $this->assertEquals('invoice', $this->model->getEntityType());
+        $this->assertEquals($this->entityType, $this->model->getEntityType());
     }
 
     public function testGetIncrementId()
@@ -160,4 +204,203 @@ class InvoiceTest extends \PHPUnit_Framework_TestCase
         $this->model->setIncrementId('test_increment_id');
         $this->assertEquals('test_increment_id', $this->model->getIncrementId());
     }
+
+    public function testSetOrder()
+    {
+        $orderId = 1111;
+        $storeId = 2221;
+        $this->orderMock->setId($orderId);
+        $this->orderMock->setStoreId($storeId);
+        $this->assertNull($this->model->getOrderId());
+        $this->assertNull($this->model->getStoreId());
+
+        $this->assertEquals($this->model, $this->model->setOrder($this->orderMock));
+        $this->assertEquals($this->orderMock, $this->model->getOrder());
+        $this->assertEquals($orderId, $this->model->getOrderId());
+        $this->assertEquals($storeId, $this->model->getStoreId());
+    }
+
+    public function testGetStore()
+    {
+        $store = $this->helperManager->getObject('\Magento\Store\Model\Store', []);
+        $this->orderMock->expects($this->once())->method('getStore')->willReturn($store);
+        $this->assertEquals($store, $this->model->getStore());
+
+    }
+
+    public function testGetShippingAddress()
+    {
+        $address = $this->helperManager->getObject('\Magento\Sales\Model\Order\Address', []);
+        $this->orderMock->expects($this->once())->method('getShippingAddress')->willReturn($address);
+        $this->assertEquals($address, $this->model->getShippingAddress());
+
+    }
+
+    /**
+     * @dataProvider canCaptureDataProvider
+     * @param string $state
+     * @param bool|null $canPaymentCapture
+     * @param bool $expectedResult
+     */
+    public function testCanCapture($state, $canPaymentCapture, $expectedResult)
+    {
+        $this->model->setState($state);
+        if (null !== $canPaymentCapture) {
+            $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
+            $this->paymentMock->expects($this->once())->method('canCapture')->willReturn($canPaymentCapture);
+        } else {
+            $this->orderMock->expects($this->never())->method('getPayment');
+            $this->paymentMock->expects($this->never())->method('canCapture');
+        }
+        $this->assertEquals($expectedResult, $this->model->canCapture());
+    }
+
+    /**
+     * Data provider for testCanCapture
+     *
+     * @return array
+     */
+    public function canCaptureDataProvider()
+    {
+        return [
+            [Invoice::STATE_OPEN, true, true],
+            [Invoice::STATE_OPEN, false, false],
+            [Invoice::STATE_CANCELED, null, false],
+            [Invoice::STATE_CANCELED, null, false],
+            [Invoice::STATE_PAID, null, false],
+            [Invoice::STATE_PAID, null, false]
+        ];
+    }
+
+    /**
+     * @dataProvider canCancelDataProvider
+     * @param string $state
+     * @param bool $expectedResult
+     */
+    public function testCanCancel($state, $expectedResult)
+    {
+        $this->model->setState($state);
+        $this->assertEquals($expectedResult, $this->model->canCancel());
+    }
+
+    /**
+     * Data provider for testCanCancel
+     *
+     * @return array
+     */
+    public function canCancelDataProvider()
+    {
+        return [
+            [Invoice::STATE_OPEN, true],
+            [Invoice::STATE_CANCELED, false],
+            [Invoice::STATE_PAID, false]
+        ];
+    }
+
+    /**
+     * @dataProvider canRefundDataProvider
+     * @param string $state
+     * @param float $baseGrandTotal
+     * @param float $baseTotalRefunded
+     * @param bool $expectedResult
+     */
+    public function testCanRefund($state, $baseGrandTotal, $baseTotalRefunded, $expectedResult)
+    {
+        $this->model->setState($state);
+        $this->model->setBaseGrandTotal($baseGrandTotal);
+        $this->model->setBaseTotalRefunded($baseTotalRefunded);
+        $this->assertEquals($expectedResult, $this->model->canRefund());
+    }
+
+    /**
+     * Data provider for testCanRefund
+     *
+     * @return array
+     */
+    public function canRefundDataProvider()
+    {
+        return [
+            [Invoice::STATE_OPEN, 0.00, 0.00, false],
+            [Invoice::STATE_CANCELED, 1.00, 0.01, false],
+            [Invoice::STATE_PAID, 1.00, 0.00, true],
+            //[Invoice::STATE_PAID, 1.00, 1.00, false]
+            [Invoice::STATE_PAID, 1.000101, 1.0000, true],
+            [Invoice::STATE_PAID, 1.0001, 1.00, false],
+            [Invoice::STATE_PAID, 1.00, 1.0001, false],
+        ];
+    }
+
+    public function testCaptureNotPaid()
+    {
+        $this->model->setIsPaid(false);
+        $this->orderMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
+        $this->paymentMock->expects($this->once())->method('capture')->with($this->model)->willReturnSelf();
+        $this->paymentMock->expects($this->never())->method('pay');
+        $this->assertEquals($this->model, $this->model->capture());
+    }
+
+    public function testCapturePaid()
+    {
+        $this->model->setIsPaid(true);
+        $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
+        $this->paymentMock->expects($this->any())->method('capture')->with($this->model)->willReturnSelf();
+        $this->mockPay(false, null);
+        $this->assertEquals($this->model, $this->model->capture());
+    }
+
+    public function mockPay($hasForcedState, $forcedState)
+    {
+        $this->orderMock->expects($this->any())->method('getPayment')->willReturn($this->paymentMock);
+        $this->paymentMock->expects($this->once())->method('hasForcedState')->willReturn($hasForcedState);
+        if ($hasForcedState) {
+            $this->paymentMock->expects($this->once())->method('getForcedState')->willReturn($forcedState);
+        } else {
+            $this->paymentMock->expects($this->never())->method('getForcedState');
+        }
+        $this->paymentMock->expects($this->once())->method('pay')->with($this->model)->willReturnSelf();
+        $this->eventManagerMock
+            ->expects($this->once())
+            ->method('dispatch')
+            ->with('sales_order_invoice_pay');
+    }
+
+    /**
+     * @dataProvider payDataProvider
+     * @param bool $hasForcedState
+     * @param float string|null $forcedState
+     * @param float $orderTotalPaid
+     * @param float $orderBaseTotalPaid
+     * @param float $grandTotal
+     * @param float $baseGrandTotal
+     * @param float $expectedState
+     */
+    public function testPay(
+        $hasForcedState,
+        $forcedState,
+        $orderTotalPaid,
+        $orderBaseTotalPaid,
+        $grandTotal,
+        $baseGrandTotal,
+        $expectedState
+    ) {
+        $this->mockPay($hasForcedState, $forcedState);
+        $this->model->setGrandTotal($grandTotal);
+        $this->model->setBaseGrandTotal($baseGrandTotal);
+        $this->orderMock->setTotalPaid($orderTotalPaid);
+        $this->orderMock->setBaseTotalPaid($orderBaseTotalPaid);
+        $this->assertFalse($this->model->wasPayCalled());
+        $this->assertEquals($this->model, $this->model->pay());
+        $this->assertTrue($this->model->wasPayCalled());
+        $this->assertEquals($expectedState, $this->model->getState());
+        #second call of pay() method must do nothing
+        $this->model->pay();
+    }
+
+    public function payDataProvider()
+    {
+        //ToDo: fill data provider and uncomment assertings totals in testPay
+        return [
+            [true, 'payment_state', 10.99, 1.00, 10.99, 1.00, 'payment_state']
+        ];
+    }
 }
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php
index 2612afa5dd8dd4717367639427060134bb87bcba..61a08ea6c877d233fdc63c859474e6e407ae4afb 100755
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php
@@ -135,6 +135,9 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
                     'canCapture',
                     'canRefund',
                     'canOrder',
+                    'order',
+                    'isInitializeNeeded',
+                    'initialize',
                 ]
             )
             ->getMock();
@@ -152,7 +155,11 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
                     'getBaseGrandTotal',
                     'getShippingAmount',
                     'getBaseShippingAmount',
-                    'getBaseTotalRefunded'
+                    'getBaseTotalRefunded',
+                    'getItemsCollection',
+                    'getOrder',
+                    'register',
+                    'capture',
                 ]
             )
             ->getMock();
@@ -175,8 +182,12 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
                     'getInvoiceCollection',
                     'addRelatedObject',
                     'getState',
+                    'getStatus',
                     'addStatusHistoryComment',
                     'registerCancellation',
+                    'getCustomerNote',
+                    'prepareInvoice',
+                    'getPaymentsCollection',
                 ]
             )
             ->getMock();
@@ -278,6 +289,223 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->payment, $this->payment->place());
     }
 
+    public function testPlaceActionOrder()
+    {
+        $newOrderStatus = 'new_status';
+        $customerNote = 'blabla';
+        $sum = 10;
+        $this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum);
+        $this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum);
+        $this->helperMock->expects($this->once())
+            ->method('getMethodInstance')
+            ->will($this->returnValue($this->paymentMethodMock));
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_ORDER);
+        $this->paymentMethodMock->expects($this->any())
+            ->method('getConfigData')
+            ->with('order_status', null)
+            ->willReturn($newOrderStatus);
+        $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $newOrderStatus, ['first', 'second']);
+        $this->orderMock->expects($this->any())
+            ->method('setState')
+            ->with(Order::STATE_PROCESSING)
+            ->willReturnSelf();
+        $this->orderMock->expects($this->any())
+            ->method('setStatus')
+            ->with($newOrderStatus)
+            ->willReturnSelf();
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(null);
+        $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
+        $this->currencyMock->method('formatTxt')->willReturn($sum);
+        $this->paymentMethodMock->expects($this->once())
+            ->method('order')
+            ->with($this->payment, $sum)
+            ->willReturnSelf();
+        $this->eventManagerMock->expects($this->at(0))
+            ->method('dispatch')
+            ->with('sales_order_payment_place_start', ['payment' => $this->payment]);
+        $this->eventManagerMock->expects($this->at(1))
+            ->method('dispatch')
+            ->with('sales_order_payment_place_end', ['payment' => $this->payment]);
+        $statusHistory = $this->getMockForAbstractClass(
+            'Magento\Sales\Api\Data\OrderStatusHistoryInterface'
+        );
+        $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote);
+        $this->orderMock->expects($this->any())
+            ->method('addStatusHistoryComment')
+            ->withConsecutive(
+                [__('Ordered amount of %1', $sum)],
+                [$customerNote]
+            )
+            ->willReturn($statusHistory);
+        $this->orderMock->expects($this->any())
+            ->method('setIsCustomerNotified')
+            ->with(true)
+            ->willReturn($statusHistory);
+        $this->assertEquals($this->payment, $this->payment->place());
+    }
+
+    public function testPlaceActionAuthorizeInitializeNeeded()
+    {
+        $newOrderStatus = 'new_status';
+        $customerNote = 'blabla';
+        $sum = 10;
+        $this->orderMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($sum);
+        $this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum);
+        $this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum);
+        $this->helperMock->expects($this->once())
+            ->method('getMethodInstance')
+            ->will($this->returnValue($this->paymentMethodMock));
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE);
+        $this->paymentMethodMock->expects($this->any())
+            ->method('getConfigData')
+            ->withConsecutive(
+                ['order_status'],
+                ['payment_action']
+            )->willReturn($newOrderStatus);
+        $this->paymentMethodMock->expects($this->once())->method('isInitializeNeeded')->willReturn(true);
+        $this->paymentMethodMock->expects($this->once())->method('initialize');
+        $this->mockGetDefaultStatus(Order::STATE_NEW, $newOrderStatus, ['first', 'second']);
+        $this->orderMock->expects($this->any())
+            ->method('setState')
+            ->with(Order::STATE_NEW)
+            ->willReturnSelf();
+        $this->orderMock->expects($this->any())
+            ->method('setStatus')
+            ->with($newOrderStatus)
+            ->willReturnSelf();
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(null);
+        $this->eventManagerMock->expects($this->at(0))
+            ->method('dispatch')
+            ->with('sales_order_payment_place_start', ['payment' => $this->payment]);
+        $this->eventManagerMock->expects($this->at(1))
+            ->method('dispatch')
+            ->with('sales_order_payment_place_end', ['payment' => $this->payment]);
+        $statusHistory = $this->getMockForAbstractClass(
+            'Magento\Sales\Api\Data\OrderStatusHistoryInterface'
+        );
+        $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote);
+        $this->orderMock->expects($this->any())
+            ->method('addStatusHistoryComment')
+            ->withConsecutive(
+                [$customerNote],
+                [__('Authorized amount of %1', $sum)]
+            )
+            ->willReturn($statusHistory);
+        $this->orderMock->expects($this->any())
+            ->method('setIsCustomerNotified')
+            ->with(true)
+            ->willReturn($statusHistory);
+        $this->assertEquals($this->payment, $this->payment->place());
+    }
+
+    public function testPlaceActionAuthorizeFraud()
+    {
+        $newOrderStatus = 'new_status';
+        $customerNote = 'blabla';
+        $sum = 10;
+        $this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum);
+        $this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum);
+        $this->helperMock->expects($this->once())
+            ->method('getMethodInstance')
+            ->will($this->returnValue($this->paymentMethodMock));
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE);
+        $this->paymentMethodMock->expects($this->any())
+            ->method('getConfigData')
+            ->with('order_status', null)
+            ->willReturn($newOrderStatus);
+        $statusHistory = $this->getMockForAbstractClass(
+            'Magento\Sales\Api\Data\OrderStatusHistoryInterface'
+        );
+        $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote);
+        $this->orderMock->expects($this->any())
+            ->method('addStatusHistoryComment')
+            ->withConsecutive(
+                [__('Order is suspended as its authorizing amount %1 is suspected to be fraudulent.', $sum)]
+            )
+            ->willReturn($statusHistory);
+        $this->mockGetDefaultStatus(Order::STATE_PROCESSING, Order::STATUS_FRAUD, ['first', 'second']);
+        $this->orderMock->expects($this->any())
+            ->method('setState')
+            ->with(Order::STATE_PROCESSING)
+            ->willReturnSelf();
+        $this->orderMock->expects($this->any())
+            ->method('setStatus')
+            ->withConsecutive(
+                [Order::STATUS_FRAUD]
+            )->willReturnSelf();
+        $this->orderMock->expects($this->atLeastOnce())
+            ->method('getStatus')
+            ->willReturn(Order::STATUS_FRAUD);
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(null);
+        $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
+        $this->currencyMock->method('formatTxt')->willReturn($sum);
+        $this->assertEquals($this->payment, $this->payment->place());
+        //maybe we don't need write authorised sum when fraud was detected
+        $this->assertEquals($sum, $this->payment->getAmountAuthorized());
+    }
+
+    public function testPlaceActionAuthorizeCapture()
+    {
+        $newOrderStatus = 'new_status';
+        $customerNote = 'blabla';
+        $sum = 10;
+        $this->orderMock->expects($this->any())->method('getTotalDue')->willReturn($sum);
+        $this->orderMock->expects($this->any())->method('getBaseTotalDue')->willReturn($sum);
+        $this->helperMock->expects($this->once())
+            ->method('getMethodInstance')
+            ->will($this->returnValue($this->paymentMethodMock));
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(\Magento\Payment\Model\Method\AbstractMethod::ACTION_AUTHORIZE_CAPTURE);
+        $this->paymentMethodMock->expects($this->any())
+            ->method('getConfigData')
+            ->with('order_status', null)
+            ->willReturn($newOrderStatus);
+        $statusHistory = $this->getMockForAbstractClass(
+            'Magento\Sales\Api\Data\OrderStatusHistoryInterface'
+        );
+        $this->invoiceMock->expects($this->once())->method('register')->willReturnSelf();
+        $this->invoiceMock->expects($this->once())->method('capture')->willReturnSelf();
+        $this->paymentMethodMock->expects($this->once())->method('canCapture')->willReturn(true);
+        $this->orderMock->expects($this->any())->method('prepareInvoice')->willReturn($this->invoiceMock);
+        $this->orderMock->expects($this->once())->method('addRelatedObject')->with($this->invoiceMock);
+        $this->orderMock->expects($this->any())->method('getCustomerNote')->willReturn($customerNote);
+        $this->orderMock->expects($this->any())
+            ->method('addStatusHistoryComment')
+            ->with($customerNote)
+            ->willReturn($statusHistory);
+        $this->mockGetDefaultStatus(Order::STATE_PROCESSING, $newOrderStatus, ['first', 'second']);
+        $this->orderMock->expects($this->any())
+            ->method('setState')
+            ->with(Order::STATE_PROCESSING)
+            ->willReturnSelf();
+        $this->orderMock->expects($this->any())
+            ->method('setStatus')
+            ->with($newOrderStatus)
+            ->willReturnSelf();
+        $this->paymentMethodMock->expects($this->once())
+            ->method('getConfigPaymentAction')
+            ->willReturn(null);
+
+        $this->assertEquals($this->payment, $this->payment->place());
+
+        $this->assertEquals($this->invoiceMock, $this->payment->getCreatedInvoice());
+        $this->assertEquals($sum, $this->payment->getAmountAuthorized());
+        $this->assertEquals($sum, $this->payment->getBaseAmountAuthorized());
+    }
+
     public function testAuthorize()
     {
         $storeID = 1;
@@ -1110,6 +1338,12 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->payment->canCapture());
     }
 
+    public function testCannotCapture()
+    {
+        $this->paymentMethodMock->expects($this->once())->method('canCapture')->willReturn(false);
+        $this->assertFalse($this->payment->canCapture());
+    }
+
     public function testPay()
     {
         $expects = [
@@ -1456,7 +1690,7 @@ class PaymentTest extends \PHPUnit_Framework_TestCase
         if (!empty($allStatuses)) {
             $orderConfigMock->expects($this->any())
                 ->method('getStateStatuses')
-                ->with(Order::STATE_NEW)
+                ->with($state)
                 ->will($this->returnValue($allStatuses));
         }
 
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..38d2772d7dadd8ddc1062c6f2f1550773be1cffd
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Status/HistoryTest.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Sales\Test\Unit\Model\Order\Status;
+
+use Magento\Sales\Model\Order\Status\History;
+
+/**
+ * Class HistoryTest
+ */
+class HistoryTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @var \Magento\Sales\Model\Order | \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $order;
+
+    /**
+     * @var History
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Store\Model\StoreManagerInterface |  \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeManager;
+
+    protected function setUp()
+    {
+        $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+
+        $this->order = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
+        $this->storeManager = $this->getMockForAbstractClass(
+            'Magento\Store\Model\StoreManagerInterface',
+            [],
+            '',
+            false
+        );
+
+
+
+        $this->model = $this->objectManager->getObject(
+            'Magento\Sales\Model\Order\Status\History',
+            ['storeManager' => $this->storeManager]
+        );
+    }
+
+    public function testSetOrder()
+    {
+        $storeId = 1;
+        $this->order->expects($this->once())->method('getStoreId')->willReturn($storeId);
+        $this->model->setOrder($this->order);
+        $this->assertEquals($this->order, $this->model->getOrder());
+    }
+
+    public function testSetIsCustomerNotified()
+    {
+        $this->model->setIsCustomerNotified(true);
+        $this->assertEquals(true, $this->model->getIsCustomerNotified());
+    }
+
+    public function testSetIsCustomerNotifiedNotApplicable()
+    {
+        $this->model->setIsCustomerNotified();
+        $this->assertEquals($this->model->isCustomerNotificationNotApplicable(), $this->model->getIsCustomerNotified());
+    }
+
+    public function testGetStatusLabel()
+    {
+        $status = 'pending';
+        $this->assertNull($this->model->getStatusLabel());
+        $this->model->setStatus($status);
+        $config = $this->getMock('Magento\Sales\Model\Order\Config', [], [], '', false);
+        $config->expects($this->once())->method('getStatusLabel')->with($status)->willReturn($status);
+        $this->order->expects($this->once())->method('getConfig')->willReturn($config);
+        $this->model->setOrder($this->order);
+        $this->assertEquals($status, $this->model->getStatusLabel());
+    }
+
+    public function testGetStoreFromStoreManager()
+    {
+        $resultStore = 1;
+        $this->storeManager->expects($this->once())->method('getStore')->willReturn($resultStore);
+        $this->assertEquals($resultStore, $this->model->getStore());
+    }
+
+    public function testGetStoreFromOrder()
+    {
+        $resultStore = 1;
+        $this->model->setOrder($this->order);
+        $this->order->expects($this->once())->method('getStore')->willReturn($resultStore);
+        $this->assertEquals($resultStore, $this->model->getStore());
+    }
+}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Resource/OrderTest.php b/app/code/Magento/Sales/Test/Unit/Model/Resource/OrderTest.php
index 647427af5956808ff1eb5505bf46ceadb7d1b23d..d8c2ec39e9b4a9665bab2d68a3380ae0f5fd5e13 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Resource/OrderTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Resource/OrderTest.php
@@ -38,10 +38,18 @@ class OrderTest extends \PHPUnit_Framework_TestCase
      * @var \Magento\Sales\Model\Order|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $orderMock;
+    /**
+     * @var \Magento\Sales\Model\Order\Item|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $orderItemMock;
     /**
      * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $storeMock;
+    /**
+     * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $websiteMock;
     /**
      * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
      */
@@ -71,8 +79,28 @@ class OrderTest extends \PHPUnit_Framework_TestCase
     {
         $this->resourceMock = $this->getMock('Magento\Framework\App\Resource', [], [], '', false);
         $this->orderMock = $this->getMock('Magento\Sales\Model\Order', [], [], '', false);
+        $this->orderItemMock = $this->getMock(
+            'Magento\Sales\Model\Order\Item',
+            ['getQuoteParentItemId', 'setTotalItemCount', 'getChildrenItems'],
+            [],
+            '',
+            false
+        );
         $this->storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
-        $this->storeGroupMock = $this->getMock('Magento\Store\Model\Group', [], [], '', false);
+        $this->storeGroupMock = $this->getMock(
+            'Magento\Store\Model\Group',
+            ['getName', 'getDefaultStoreId'],
+            [],
+            '',
+            false
+        );
+        $this->websiteMock = $this->getMock(
+            'Magento\Store\Model\Website',
+            ['getName'],
+            [],
+            '',
+            false
+        );
         $this->adapterMock = $this->getMock(
             'Magento\Framework\DB\Adapter\Pdo\Mysql',
             [
@@ -138,7 +166,24 @@ class OrderTest extends \PHPUnit_Framework_TestCase
 
     public function testSave()
     {
-
+        $this->orderMock->expects($this->exactly(3))
+            ->method('getId')
+            ->willReturn(null);
+        $this->orderItemMock->expects($this->once())
+            ->method('getChildrenItems')
+            ->willReturn([]);
+        $this->orderItemMock->expects($this->once())
+            ->method('getQuoteParentItemId')
+            ->willReturn(null);
+        $this->orderMock->expects($this->once())
+            ->method('setTotalItemCount')
+            ->with(1);
+        $this->storeGroupMock->expects($this->once())
+            ->method('getDefaultStoreId')
+            ->willReturn(1);
+        $this->orderMock->expects($this->once())
+            ->method('getAllItems')
+            ->willReturn([$this->orderItemMock]);
         $this->orderMock->expects($this->once())
             ->method('validateBeforeSave')
             ->willReturnSelf();
@@ -151,12 +196,15 @@ class OrderTest extends \PHPUnit_Framework_TestCase
         $this->orderMock->expects($this->once())
             ->method('getEntityType')
             ->willReturn('order');
-        $this->orderMock->expects($this->once())
+        $this->orderMock->expects($this->exactly(2))
             ->method('getStore')
             ->willReturn($this->storeMock);
-        $this->storeMock->expects($this->once())
+        $this->storeMock->expects($this->exactly(2))
             ->method('getGroup')
             ->willReturn($this->storeGroupMock);
+        $this->storeMock->expects($this->once())
+            ->method('getWebsite')
+            ->willReturn($this->websiteMock);
         $this->storeGroupMock->expects($this->once())
             ->method('getDefaultStoreId')
             ->willReturn(1);
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_grid_block.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_grid_block.xml
index 3cbec907dc9bfeefbf9342c6631b65789b75ff82..89365d27a1124b0abc5c3d2baf51421731a9a2b8 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_grid_block.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_invoice_grid_block.xml
@@ -70,13 +70,13 @@
                             <argument name="column_css_class" xsi:type="string">col-status</argument>
                         </arguments>
                     </block>
-                    <block class="Magento\Backend\Block\Widget\Grid\Column" as="base_grand_total">
+                    <block class="Magento\Backend\Block\Widget\Grid\Column" as="grand_total">
                         <arguments>
-                            <argument name="id" xsi:type="string">base_grand_total</argument>
+                            <argument name="id" xsi:type="string">grand_total</argument>
                             <argument name="header" xsi:type="string" translate="true">Amount</argument>
                             <argument name="type" xsi:type="string">currency</argument>
-                            <argument name="currency" xsi:type="string">base_currency_code</argument>
-                            <argument name="index" xsi:type="string">base_grand_total</argument>
+                            <argument name="currency" xsi:type="string">order_currency_code</argument>
+                            <argument name="index" xsi:type="string">grand_total</argument>
                             <argument name="header_css_class" xsi:type="string">col-qty</argument>
                             <argument name="column_css_class" xsi:type="string">col-qty</argument>
                         </arguments>
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
index 13f6704f34d37fb5ae8773e7c2628d402a28a5dd..7cdb49ff39e1c2c414ec93c3b39d2586eeabfaee 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
@@ -40,8 +40,12 @@ define([
     return Collapsible.extend({
         defaults: {
             template: 'ui/grid/filters/filters',
-            applied: {},
-            filters: {},
+            applied: {
+                placeholder: true
+            },
+            filters: {
+                placeholder: true
+            },
             chipsConfig: {
                 name: '${ $.name }_chips',
                 provider: '${ $.chipsConfig.name }',
@@ -151,25 +155,11 @@ define([
          * @returns {Filters} Chainable.
          */
         cancel: function () {
-            this.convertToObject();
             this.set('filters', utils.copy(this.applied));
 
             return this;
         },
 
-        /**
-         * Convert empty array to empty object.
-         *
-         * @returns {Filters} Chainable.
-         */
-        convertToObject: function() {
-            if ( _.isArray(this.applied) && _.isEmpty(this.applied) ) {
-                this.applied = {};
-            }
-
-            return this;
-        },
-
         /**
          * Tells wether filters pannel should be opened.
          *
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js
index 852bae6d580647a66e1106d9168af69617b821bd..71e0570311aea9a9b4144a51340504846d7acd38 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/search/search.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/search/search.js
@@ -16,6 +16,7 @@ define([
             template: 'ui/grid/search/search',
             placeholder: $t('Search by keyword'),
             label: $t('Keyword'),
+            value: '',
             imports: {
                 inputValue: 'value',
                 updatePreview: 'value'
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php
index a2e6205071db7f2a9b4f1b80444ebfb1ac304c8a..9fbf676b355ed107dcb1db23c847ff5499643e04 100644
--- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Block/Product/View/Type/ConfigurableTest.php
@@ -69,7 +69,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
             $this->assertInstanceOf('Magento\Catalog\Model\Product', $product);
         }
     }
-    
+
     /**
      * @magentoAppIsolation enabled
      */
@@ -79,7 +79,6 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
         $this->assertNotEmpty($config);
         $this->assertArrayHasKey('productId', $config);
         $this->assertEquals(1, $config['productId']);
-        $this->assertArrayHasKey('baseImage', $config);
         $this->assertArrayHasKey('attributes', $config);
         $this->assertArrayHasKey('template', $config);
         $this->assertArrayHasKey('prices', $config);