diff --git a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php
index e96a83a31eba907e26515f87bcf4439e6999112a..e31de3cde7727f6a6ed98b5795098c42d64a5ed3 100644
--- a/app/code/Magento/Authorization/Model/Acl/AclRetriever.php
+++ b/app/code/Magento/Authorization/Model/Acl/AclRetriever.php
@@ -75,7 +75,9 @@ class AclRetriever
         try {
             $role = $this->_getUserRole($userType, $userId);
             if (!$role) {
-                throw new AuthorizationException('The role associated with the specified user cannot be found.');
+                throw new AuthorizationException(
+                    __('The role associated with the specified user cannot be found.')
+                );
             }
             $allowedResources = $this->getAllowedResourcesByRole($role->getId());
         } catch (AuthorizationException $e) {
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php
index fa374e9cbd2568dedf9316289cc6e1932c900671..143b12d06c3c933884219888577c3e06e856869c 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Ajax/Translate.php
@@ -16,19 +16,19 @@ class Translate extends \Magento\Backend\App\Action
     protected $inlineParser;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param Action\Context $context
      * @param \Magento\Framework\Translate\Inline\ParserInterface $inlineParser
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         Action\Context $context,
         \Magento\Framework\Translate\Inline\ParserInterface $inlineParser,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -38,13 +38,13 @@ class Translate extends \Magento\Backend\App\Action
     /**
      * Ajax action for inline translation
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
         $translate = (array)$this->getRequest()->getPost('translate');
 
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         try {
             $this->inlineParser->processAjaxPost($translate);
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php b/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php
index 33b251ca19dc30e1e590e05c4a13036ac9e2b0d4..43062aa6908a3bf411201bee43ecf28852e14d19 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Auth/DeniedJson.php
@@ -9,17 +9,17 @@ namespace Magento\Backend\Controller\Adminhtml\Auth;
 class DeniedJson extends \Magento\Backend\Controller\Adminhtml\Auth
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -41,11 +41,11 @@ class DeniedJson extends \Magento\Backend\Controller\Adminhtml\Auth
     /**
      * Denied JSON action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($this->_getDeniedJson());
     }
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
index 7b0e02e7d1e113e666fbbfb497790123344be1c9..f200ef062d37f9ef991f581fb20636b8677919b7 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache.php
@@ -74,7 +74,7 @@ class Cache extends Action
         $allTypes = array_keys($this->_cacheTypeList->getTypes());
         $invalidTypes = array_diff($types, $allTypes);
         if (count($invalidTypes) > 0) {
-            throw new LocalizedException(__("Specified cache type(s) don't exist: " . join(', ', $invalidTypes)));
+            throw new LocalizedException(__('Specified cache type(s) don\'t exist: %1', join(', ', $invalidTypes)));
         }
     }
 
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php
index c0017958a0bc88b09ab151f24faae155f483fd78..ba71fa71ec1d8dd23c085509d9f2672cc092824f 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/Index/GlobalSearch.php
@@ -9,7 +9,7 @@ namespace Magento\Backend\Controller\Adminhtml\Index;
 class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -22,12 +22,12 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param array $searchModules
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         array $searchModules = []
     ) {
         $this->_searchModules = $searchModules;
@@ -38,7 +38,7 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index
     /**
      * Global Search Action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -87,7 +87,7 @@ class GlobalSearch extends \Magento\Backend\Controller\Adminhtml\Index
             }
         }
 
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($items);
     }
diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php
index d12a3141841d9d9b1b32ea400c347c6c6673c29b..86ec95f344e19d2fade1d60582365ffa98bfedf3 100644
--- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php
+++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php
@@ -78,7 +78,7 @@ class Save extends \Magento\Backend\Controller\Adminhtml\System\Account
                 $user->sendPasswordResetNotificationEmail();
             }
             $this->messageManager->addSuccess(__('The account has been saved.'));
-        } catch (\Magento\Framework\Validator\ValidatorException $e) {
+        } catch (\Magento\Framework\Validator\Exception $e) {
             $this->messageManager->addMessages($e->getMessages());
             if ($e->getMessage()) {
                 $this->messageManager->addError($e->getMessage());
diff --git a/app/code/Magento/Backend/Model/Auth.php b/app/code/Magento/Backend/Model/Auth.php
index 883bd5c2ddadee1847d47d409c6b1a75439276e9..53cf5d5a6f94e9a814a1fa8483b174ab34e5e55c 100644
--- a/app/code/Magento/Backend/Model/Auth.php
+++ b/app/code/Magento/Backend/Model/Auth.php
@@ -7,6 +7,7 @@ namespace Magento\Backend\Model;
 
 use Magento\Framework\Exception\AuthenticationException;
 use Magento\Framework\Exception\Plugin\AuthenticationException as PluginAuthenticationException;
+use Magento\Framework\Phrase;
 
 /**
  * Backend Auth model
@@ -81,7 +82,7 @@ class Auth
     public function setAuthStorage($storage)
     {
         if (!$storage instanceof \Magento\Backend\Model\Auth\StorageInterface) {
-            self::throwException('Authentication storage is incorrect.');
+            self::throwException(__('Authentication storage is incorrect.'));
         }
         $this->_authStorage = $storage;
         return $this;
@@ -199,12 +200,12 @@ class Auth
     /**
      * Throws specific Backend Authentication \Exception
      *
-     * @param string $msg
+     * @param \Magento\Framework\Phrase $msg
      * @return void
      * @throws \Magento\Framework\Exception\AuthenticationException
      * @static
      */
-    public static function throwException($msg = null)
+    public static function throwException(Phrase $msg = null)
     {
         if (is_null($msg)) {
             $msg = __('Authentication error occurred.');
diff --git a/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php b/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php
index 8cb5621e70f311c6845c580b748e87f29e2aa7ba..d27a5f464ec1243651cd387240a1c21b90630698 100644
--- a/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php
+++ b/app/code/Magento/Backend/Model/View/Layout/GeneratorPool.php
@@ -22,6 +22,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool
      * @param ScheduledStructure\Helper $helper
      * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
      * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
+     * @param \Psr\Log\LoggerInterface $logger
      * @param Filter\Acl $aclFilter
      * @param array $generators
      */
@@ -29,6 +30,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool
         ScheduledStructure\Helper $helper,
         \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
         \Magento\Framework\App\ScopeResolverInterface $scopeResolver,
+        \Psr\Log\LoggerInterface $logger,
         Filter\Acl $aclFilter,
         array $generators = null
     ) {
@@ -37,6 +39,7 @@ class GeneratorPool extends \Magento\Framework\View\Layout\GeneratorPool
             $helper,
             $scopeConfig,
             $scopeResolver,
+            $logger,
             $generators
         );
     }
diff --git a/app/code/Magento/Backend/etc/adminhtml/system.xml b/app/code/Magento/Backend/etc/adminhtml/system.xml
index dabe16d4a344a40ef93769cd7700fff2ad0806e4..6dd6d3ea9d992df5b4907094abebd2127827a41a 100644
--- a/app/code/Magento/Backend/etc/adminhtml/system.xml
+++ b/app/code/Magento/Backend/etc/adminhtml/system.xml
@@ -179,6 +179,10 @@
                     <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                     <comment>Warning! Enabling this feature is not recommended on production environments because it represents a potential security risk.</comment>
                 </field>
+                <field id="minify_html" translate="label" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
+                    <label>Minify Html</label>
+                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
+                </field>
             </group>
             <group id="translate_inline" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                 <label>Translate Inline</label>
diff --git a/app/code/Magento/Backend/etc/config.xml b/app/code/Magento/Backend/etc/config.xml
index 0d4c5d7180513828a1fd452c6c17d3847b8910d3..ea2586bae427a78a76e1fe2eb2e36077c8683824 100644
--- a/app/code/Magento/Backend/etc/config.xml
+++ b/app/code/Magento/Backend/etc/config.xml
@@ -7,6 +7,11 @@
 -->
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Store/etc/config.xsd">
     <default>
+        <dev>
+            <template>
+                <minify_html>1</minify_html>
+            </template>
+        </dev>
         <system>
             <media_storage_configuration>
                 <allowed_resources>
diff --git a/app/code/Magento/Backup/Model/Backup.php b/app/code/Magento/Backup/Model/Backup.php
index 73f9ec7cac8b6a6e3295ab3187cb65abf3048c45..a0d44f44641b9d801d546a3869e73c34e48cf0d7 100755
--- a/app/code/Magento/Backup/Model/Backup.php
+++ b/app/code/Magento/Backup/Model/Backup.php
@@ -246,7 +246,7 @@ class Backup extends \Magento\Framework\Object implements \Magento\Framework\Bac
     public function &getFile()
     {
         if (!$this->exists()) {
-            throw new \Magento\Framework\Exception\LocalizedException(__("The backup file does not exist."));
+            throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.'));
         }
 
         return $this->varDirectory->read($this->_getFilePath());
@@ -261,7 +261,7 @@ class Backup extends \Magento\Framework\Object implements \Magento\Framework\Bac
     public function deleteFile()
     {
         if (!$this->exists()) {
-            throw new \Magento\Framework\Exception\LocalizedException(__("The backup file does not exist."));
+            throw new \Magento\Framework\Exception\LocalizedException(__('The backup file does not exist.'));
         }
 
         $this->varDirectory->delete($this->_getFilePath());
diff --git a/app/code/Magento/Bundle/Model/LinkManagement.php b/app/code/Magento/Bundle/Model/LinkManagement.php
index 408747b81e500ca07a4fb8125733e0a0a6fe1960..fe2c0d85d7b168d21183813afc8b72ffbb9f280e 100644
--- a/app/code/Magento/Bundle/Model/LinkManagement.php
+++ b/app/code/Magento/Bundle/Model/LinkManagement.php
@@ -79,9 +79,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
     {
         $product = $this->productRepository->get($productId);
         if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
-            throw new InputException(
-                'Only implemented for bundle product'
-            );
+            throw new InputException(__('Only implemented for bundle product'));
         }
 
         $childrenList = [];
@@ -115,7 +113,9 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
         \Magento\Bundle\Api\Data\LinkInterface $linkedProduct
     ) {
         if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
-            throw new InputException('Product with specified sku: "%1" is not a bundle product', [$product->getSku()]);
+            throw new InputException(
+                __('Product with specified sku: "%1" is not a bundle product', $product->getSku())
+            );
         }
 
         $options = $this->optionCollection->create();
@@ -131,8 +131,10 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
 
         if ($isNewOption) {
             throw new InputException(
-                'Product with specified sku: "%1" does not contain option: "%2"',
-                [$product->getSku(), $optionId]
+                __(
+                    'Product with specified sku: "%1" does not contain option: "%2"',
+                    [$product->getSku(), $optionId]
+                )
             );
         }
 
@@ -142,15 +144,17 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
         /** @var \Magento\Catalog\Model\Product $linkProductModel */
         $linkProductModel = $this->productRepository->get($linkedProduct->getSku());
         if ($linkProductModel->isComposite()) {
-            throw new InputException('Bundle product could not contain another composite product');
+            throw new InputException(__('Bundle product could not contain another composite product'));
         }
         if ($selections) {
             foreach ($selections as $selection) {
                 if ($selection['option_id'] == $optionId &&
                     $selection['product_id'] == $linkProductModel->getId()) {
                     throw new CouldNotSaveException(
-                        'Child with specified sku: "%1" already assigned to product: "%2"',
-                        [$linkedProduct->getSku(), $product->getSku()]
+                        __(
+                            'Child with specified sku: "%1" already assigned to product: "%2"',
+                            [$linkedProduct->getSku(), $product->getSku()]
+                        )
                     );
                 }
             }
@@ -171,7 +175,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
         try {
             $selectionModel->save();
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save child: "%1"', [$e->getMessage()], $e);
+            throw new CouldNotSaveException(__('Could not save child: "%1"', $e->getMessage()), $e);
         }
 
         return $selectionModel->getId();
@@ -185,9 +189,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
         $product = $this->productRepository->get($sku);
 
         if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
-            throw new InputException(
-                sprintf('Product with specified sku: %s is not a bundle product', $sku)
-            );
+            throw new InputException(__('Product with specified sku: %1 is not a bundle product', $sku));
         }
 
         $excludeSelectionIds = [];
@@ -206,7 +208,7 @@ class LinkManagement implements \Magento\Bundle\Api\ProductLinkManagementInterfa
         }
         if (empty($removeSelectionIds)) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(
-                'Requested bundle option product doesn\'t exist'
+                __('Requested bundle option product doesn\'t exist')
             );
         }
         /* @var $resource \Magento\Bundle\Model\Resource\Bundle */
diff --git a/app/code/Magento/Bundle/Model/OptionManagement.php b/app/code/Magento/Bundle/Model/OptionManagement.php
index e4053895111dbc12c4f5d6aabb1170e61ec84a95..714cb45a5662535884a5cfeb2f03fb6176171ba7 100644
--- a/app/code/Magento/Bundle/Model/OptionManagement.php
+++ b/app/code/Magento/Bundle/Model/OptionManagement.php
@@ -39,7 +39,7 @@ class OptionManagement implements \Magento\Bundle\Api\ProductOptionManagementInt
     {
         $product = $this->productRepository->get($option->getSku());
         if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
-            throw new InputException('Only implemented for bundle product');
+            throw new InputException(__('Only implemented for bundle product'));
         }
         return $this->optionRepository->save($product, $option);
     }
diff --git a/app/code/Magento/Bundle/Model/OptionRepository.php b/app/code/Magento/Bundle/Model/OptionRepository.php
index b9d42b974803e7f913e21e196601083be313d0d9..264a7f1d159eccde62e0d2b6ce90855627c648d2 100644
--- a/app/code/Magento/Bundle/Model/OptionRepository.php
+++ b/app/code/Magento/Bundle/Model/OptionRepository.php
@@ -103,7 +103,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt
         /** @var \Magento\Bundle\Model\Option $option */
         $option = $this->type->getOptionsCollection($product)->getItemById($optionId);
         if (!$option || !$option->getId()) {
-            throw new NoSuchEntityException('Requested option doesn\'t exist');
+            throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
         }
 
         $productLinks = $this->linkList->getItems($product, $optionId);
@@ -141,8 +141,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt
             $this->optionResource->delete($option);
         } catch (\Exception $exception) {
             throw new \Magento\Framework\Exception\StateException(
-                'Cannot delete option with id %option_id',
-                ['option_id' => $option->getOptionId()],
+                __('Cannot delete option with id %1', $option->getOptionId()),
                 $exception
             );
         }
@@ -182,7 +181,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt
             $existingOption = $optionCollection->getFirstItem();
 
             if (!$existingOption->getOptionId()) {
-                throw new NoSuchEntityException('Requested option doesn\'t exist');
+                throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
             }
 
             $option->setData(array_merge($existingOption->getData(), $option->getData()));
@@ -205,7 +204,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt
         try {
             $this->optionResource->save($option);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save option', [], $e);
+            throw new CouldNotSaveException(__('Could not save option'), $e);
         }
 
         /** @var \Magento\Bundle\Api\Data\LinkInterface $linkedProduct */
@@ -225,7 +224,7 @@ class OptionRepository implements \Magento\Bundle\Api\ProductOptionRepositoryInt
     {
         $product = $this->productRepository->get($sku);
         if ($product->getTypeId() != \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) {
-            throw new InputException('Only implemented for bundle product');
+            throw new InputException(__('Only implemented for bundle product'));
         }
         return $product;
     }
diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php
index 887aebbf7f669f30bd8cb463d6e6b147e4e3dc9e..1fdd7bad95292de7c985b119b155091be9659950 100644
--- a/app/code/Magento/Bundle/Model/Product/Type.php
+++ b/app/code/Magento/Bundle/Model/Product/Type.php
@@ -678,7 +678,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
 
         try {
             if (is_string($result)) {
-                throw new \Magento\Framework\Exception\LocalizedException($result);
+                throw new \Magento\Framework\Exception\LocalizedException(__($result));
             }
 
             $selections = [];
@@ -1314,7 +1314,7 @@ class Type extends \Magento\Catalog\Model\Product\Type\AbstractType
     protected function checkIsResult($_result)
     {
         if (is_string($_result)) {
-            throw new \Magento\Framework\Exception\LocalizedException($_result);
+            throw new \Magento\Framework\Exception\LocalizedException(__($_result));
         }
 
         if (!isset($_result[0])) {
diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
index c4aab7ef84c20a7829f64b6f0ef538eb82b54f37..168fa5363ab0a943f185f78b345169a1f0427d98 100644
--- a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
+++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
@@ -61,6 +61,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
      */
     private $priceCurrency;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->bundleCollection = $this->getMockBuilder('Magento\Bundle\Model\Resource\Selection\CollectionFactory')
@@ -119,6 +122,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedWithoutOptions()
@@ -227,6 +231,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedWithShoppingCart()
@@ -466,6 +471,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedEmptyShoppingCart()
@@ -684,6 +690,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedStringInResult()
@@ -902,6 +909,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedWithoutSelections()
@@ -1007,6 +1015,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedSelectionsSelectionIdsExists()
@@ -1134,6 +1143,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testPrepareForCartAdvancedSelectRequiredOptions()
@@ -1255,6 +1265,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('The required options you selected are not available.', $result);
     }
 
+    /**
+     * @return void
+     */
     public function testPrepareForCartAdvancedParentClassReturnString()
     {
         $exceptedResult = 'String message';
@@ -1270,13 +1283,15 @@ class TypeTest extends \PHPUnit_Framework_TestCase
             ->getMock();
         $product->expects($this->at(0))
             ->method('getOptions')
-            ->willThrowException(new LocalizedException($exceptedResult));
+            ->willThrowException(new LocalizedException(__($exceptedResult)));
 
         $result = $this->model->prepareForCartAdvanced($buyRequest, $product);
         $this->assertEquals($exceptedResult, $result);
     }
 
-
+    /**
+     * @return void
+     */
     public function testPrepareForCartAdvancedAllrequiredOption()
     {
         /** @var \PHPUnit_Framework_MockObject_MockObject|DefaultType $group */
@@ -1374,6 +1389,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('Please select all required options.', $result);
     }
 
+    /**
+     * @return void
+     */
     public function testPrepareForCartAdvancedSpecifyProductOptions()
     {
         /** @var \PHPUnit_Framework_MockObject_MockObject|DefaultType $group */
@@ -1423,11 +1441,17 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('Please specify product option(s).', $result);
     }
 
+    /**
+     * @return void
+     */
     public function testHasWeightTrue()
     {
         $this->assertTrue($this->model->hasWeight(), 'This product has no weight, but it should');
     }
 
+    /**
+     * @return void
+     */
     public function testGetIdentities()
     {
         $identities = ['id1', 'id2'];
@@ -1469,6 +1493,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($identities, $this->model->getIdentities($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testGetSkuWithType()
     {
         $sku = 'sku';
@@ -1487,6 +1514,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($sku, $this->model->getSku($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testGetSkuWithoutType()
     {
         $sku = 'sku';
@@ -1539,6 +1569,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($sku . '-' . $itemSku, $this->model->getSku($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testGetWeightWithoutCustomOption()
     {
         $weight = 5;
@@ -1559,6 +1592,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($weight, $this->model->getWeight($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testGetWeightWithCustomOption()
     {
         $weight = 5;
@@ -1610,6 +1646,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($weight, $this->model->getWeight($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testGetWeightWithSeveralCustomOption()
     {
         $weight = 5;
@@ -1668,6 +1707,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($weight * $qtyOption, $this->model->getWeight($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testIsVirtualWithoutCustomOption()
     {
         $productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
@@ -1681,6 +1723,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->isVirtual($productMock));
     }
 
+    /**
+     * @return void
+     */
     public function testIsVirtual()
     {
         $selectionIds = [1, 2, 3];
@@ -1726,10 +1771,10 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @param $selectionIds
-     * @param $productMock
-     * @param $getSelectionsIndex
-     * @param $getSelectionsIdsIndex
+     * @param array $selectionIds
+     * @param \PHPUnit_Framework_MockObject_MockObject $productMock
+     * @param int $getSelectionsIndex
+     * @param int $getSelectionsIdsIndex
      * @return \PHPUnit_Framework_MockObject_MockObject
      */
 
@@ -1752,9 +1797,10 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @param $expected
-     * @param $firstId
-     * @param $secondId
+     * @param int $expected
+     * @param int $firstId
+     * @param int $secondId
+     * @return void
      * @dataProvider shakeSelectionsDataProvider
      */
     public function testShakeSelections($expected, $firstId, $secondId)
@@ -1823,6 +1869,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testGetSelectionsByIds()
@@ -1926,6 +1973,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->model->getSelectionsByIds($selectionIds, $productMock);
     }
 
+    /**
+     * @return void
+     */
     public function testGetOptionsByIds()
     {
         $optionsIds = [1, 2, 3];
@@ -1997,6 +2047,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->model->getOptionsByIds($optionsIds, $productMock);
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableFalse()
     {
         $product = new \Magento\Framework\Object(
@@ -2009,6 +2062,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableWithoutOptions()
     {
         $optionCollectionMock = $this->getMockBuilder('\Magento\Bundle\Model\Resource\Option\Collection')
@@ -2026,6 +2082,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableWithRequiredOptionsTrue()
     {
         $option1 = $this->getRequiredOptionMock(10, 10);
@@ -2071,6 +2130,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableCache()
     {
         $product = new \Magento\Framework\Object(
@@ -2084,6 +2146,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableWithEmptySelectionsCollection()
     {
         $option = $this->getRequiredOptionMock(1, 10);
@@ -2102,6 +2167,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableWithRequiredOptionsOutOfStock()
     {
         $option1 = $this->getRequiredOptionMock(10, 10);
@@ -2145,6 +2213,9 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->isSalable($product));
     }
 
+    /**
+     * @return void
+     */
     public function testIsSalableNoManageStock()
     {
         $option1 = $this->getRequiredOptionMock(10, 10);
@@ -2274,11 +2345,13 @@ class TypeTest extends \PHPUnit_Framework_TestCase
         return $optionCollectionMock;
     }
 
+    /**
+     * @param bool $isManageStock
+     * @return \Magento\CatalogInventory\Api\Data\StockItemInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
     protected function getStockItem($isManageStock)
     {
-        $result = $this->getMockBuilder('\Magento\CatalogInventory\Api\Data\StockItem')
-            ->setMethods(['getManageStock'])
-            ->disableOriginalConstructor()
+        $result = $this->getMockBuilder('Magento\CatalogInventory\Api\Data\StockItemInterface')
             ->getMock();
         $result->method('getManageStock')
             ->willReturn($isManageStock);
@@ -2291,6 +2364,7 @@ class TypeTest extends \PHPUnit_Framework_TestCase
      * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product\Option $option
      * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Object $buyRequest
      * @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Product $product
+     * @return void
      */
     protected function parentClass($group, $option, $buyRequest, $product)
     {
diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/checkbox.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/checkbox.phtml
index bcc039467893ee6422bb34cb2a5ab8e326eca45d..930efcfb1c1aa92dc4278cbd19f997529a32d1b7 100644
--- a/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/checkbox.phtml
+++ b/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/checkbox.phtml
@@ -30,7 +30,7 @@
     echo 'validate-one-required-by-name' ?>"
                     id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"
                     type="checkbox"
-                    name="bundle_option[<?php echo $_option->getId() ?>][]"<?php if ($block->isSelected($_selection)) {
+                    name="bundle_option[<?php echo $_option->getId() ?>][<?php echo $_selection ?>]"<?php if ($block->isSelected($_selection)) {
     echo ' checked="checked"' ?><?php if (!$_selection->isSaleable() && !$_skipSaleableCheck) {
     echo ' disabled="disabled"' ?>
                     value="<?php echo $_selection->getSelectionId() ?>"
diff --git a/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/multi.phtml b/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/multi.phtml
index d8b5d461196b9d55fe440083ac160a17315e9652..03922735e0c8ec34f66563eb556920916de57d5b 100644
--- a/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/multi.phtml
+++ b/app/code/Magento/Bundle/view/adminhtml/templates/product/composite/fieldset/options/type/multi.phtml
@@ -21,7 +21,7 @@
                    price="<?php echo $block->getSelectionPrice($_selections[0]) ?>" />
         <?php else: ?>
             <select multiple="multiple" size="5" id="bundle-option-<?php echo $_option->getId() ?>"
-                    name="bundle_option[<?php echo $_option->getId() ?>][]"
+                    name="bundle_option[<?php echo $_option->getId() ?>]"
                     class="bundle-option-<?php echo $_option->getId() ?><?php if ($_option->getRequired()) echo ' required-entry' ?> multiselect change-container-classname"
                     onchange="ProductConfigure.bundleControl.changeSelection(this)">
             <?php if(!$_option->getRequired()): ?>
diff --git a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
index 588184ee564d2d2d381250347d8f9fcce9034e1f..00938f3c70c0f58427e5b1302dc9c77f3ee6ed0c 100644
--- a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
+++ b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml
@@ -30,7 +30,7 @@
                                id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"
                                type="checkbox"
                                <?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':true}"'?>
-                               name="bundle_option[<?php echo $_option->getId() ?>][]"
+                               name="bundle_option[<?php echo $_option->getId() ?>][<?php echo $_selection->getId() ?>]"
                                <?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
                                <?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
                                value="<?php echo $_selection->getSelectionId() ?>"/>
diff --git a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/multi.phtml b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/multi.phtml
index 81cb30bc6f7cf4e8a5eb0d624c72035809eb0ab5..5c32f9c42a23c300464df14ee8292b203755b8da 100644
--- a/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/multi.phtml
+++ b/app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/multi.phtml
@@ -24,7 +24,7 @@
             <select multiple="multiple"
                     size="5"
                     id="bundle-option-<?php echo $_option->getId() ?>"
-                    name="bundle_option[<?php echo $_option->getId() ?>][]"
+                    name="bundle_option[<?php echo $_option->getId() ?>]"
                     class="bundle-option-<?php echo $_option->getId() ?> multiselect product bundle option change-container-classname"
                     <?php if ($_option->getRequired()) echo 'data-validate={required:true}' ?>>
                 <?php if(!$_option->getRequired()): ?>
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php
index d8bb23af05313da1f5ca6e4712f49aa0b6c9af97..5fec84fb27a853f3eccfccab7abd20425672dd7f 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/CategoriesJson.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
@@ -57,7 +57,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category
                 $resultRedirect = $this->resultRedirectFactory->create();
                 return $resultRedirect->setPath('catalog/*/', ['_current' => true, 'id' => null]);
             }
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setJsonData(
                 $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree')
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php
index f6b54278aa3eabc0a117ebf45ad491337a5fe39a..0d0b763cfec6bc93832e2ebd25fff308328a3030 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Edit.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class Edit extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -22,13 +22,13 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
         $this->resultPageFactory = $resultPageFactory;
@@ -106,7 +106,7 @@ class Edit extends \Magento\Catalog\Controller\Adminhtml\Category
                 'category_prepare_ajax_response',
                 ['response' => $eventResponse, 'controller' => $this]
             );
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             $resultJson->setHeader('Content-type', 'application/json', true);
             $resultJson->setData($eventResponse->getData());
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php
index 4a1fc8d7ea995ab2f132402f6b048e33f5aed705..c35247eaacf7946444fb1fa0d89f1a47ff8a8a86 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Move.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class Move extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -26,14 +26,14 @@ class Move extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory,
      * @param \Psr\Log\LoggerInterface $logger,
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory,
         \Psr\Log\LoggerInterface $logger
     ) {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php
index 8f1af886e441e14b83b43c7a71d459eefc359d2c..8b19840c3c083f0b8ec8554d7f48eb2133849583 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/RefreshPath.php
@@ -9,19 +9,19 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -30,7 +30,7 @@ class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * Build response for refresh input element 'path' in form
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -38,7 +38,7 @@ class RefreshPath extends \Magento\Catalog\Controller\Adminhtml\Category
         if ($categoryId) {
             $category = $this->_objectManager->create('Magento\Catalog\Model\Category')->load($categoryId);
 
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData(['id' => $categoryId, 'path' => $category->getPath()]);
         }
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
index 92b1f5609332922b96e14e3ef1cb8f6883ed97ff..01f622f6996f39a791fa04ebc25eb16c4bce79a9 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
@@ -16,7 +16,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
     protected $resultRawFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -31,14 +31,14 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
@@ -153,7 +153,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
                                 __('Attribute "%1" is required.', $attribute)
                             );
                         } else {
-                            throw new \Magento\Framework\Exception\LocalizedException($error);
+                            throw new \Magento\Framework\Exception\LocalizedException(__($error));
                         }
                     }
                 }
@@ -180,7 +180,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
             $block = $this->layoutFactory->create()->getMessagesBlock();
             $block->setMessages($this->messageManager->getMessages(true));
 
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData(
                 [
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php
index 800a4726e96cd3be2f2fde25ff701b82f72b4a47..14d7bf780c053563758b86b5e8cd39a8fa3b519c 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/SuggestCategories.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
@@ -38,11 +38,11 @@ class SuggestCategories extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * Category list suggestion based on already entered symbols
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setJsonData(
             $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree')
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php
index b7410f3ada3ee5558c1c7a1825eee36ac2d3c7aa..6604d3fc116a0b06793eece09e869076c6a663b6 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Tree.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category;
 class Tree extends \Magento\Catalog\Controller\Adminhtml\Category
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $resultRedirectFactory);
@@ -65,7 +65,7 @@ class Tree extends \Magento\Catalog\Controller\Adminhtml\Category
 
         $block = $this->layoutFactory->create()->createBlock('Magento\Catalog\Block\Adminhtml\Category\Tree');
         $root = $block->getRoot();
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData([
             'data' => $block->getTree(),
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php
index aeb4186f9118b5cc57ccbfc67b0a22413c9e1951..329f786314fb2f972cdc769f08ef68305c0d469b 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Widget/CategoriesJson.php
@@ -16,20 +16,20 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg
     protected $_coreRegistry;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Registry $coreRegistry
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\View\LayoutFactory $layoutFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Registry $coreRegistry
     ) {
         parent::__construct($context, $layoutFactory);
@@ -40,7 +40,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg
     /**
      * Categories tree node (Ajax version)
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -53,7 +53,7 @@ class CategoriesJson extends \Magento\Catalog\Controller\Adminhtml\Category\Widg
                 $this->_coreRegistry->register('current_category', $category);
             }
             $categoryTreeBlock = $this->_getCategoryTreeBlock()->setSelectedCategories(explode(',', $selected));
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setJsonData($categoryTreeBlock->getTreeJson($category));
         }
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php
index b487743f5c69934bbb79f375e7c0ade9ab728f10..096e32642cbe2dc2c23148cdc46cb9714e5e885a 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Validate.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute;
 class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Action\Attr
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Catalog\Helper\Product\Edit\Action\Attribute $attributeHelper,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $attributeHelper);
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php
index 8f0a3de052a755ba072cbd7064c1d39f1395297a..6cd7b5d2546bfcf7a0761cc902efb9e930ccff21 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php
@@ -9,19 +9,19 @@ namespace Magento\Catalog\Controller\Adminhtml\Product;
 class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Product
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context, $productBuilder);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -29,7 +29,7 @@ class AddAttributeToTemplate extends \Magento\Catalog\Controller\Adminhtml\Produ
     /**
      * Add attribute to product template
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
index f6b4582d3a882a9e9ab81ffc05ffdf410ccd40e9..4f564351eae2418de9a738ebb50d28348a7c5d96 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product\Attribute;
 class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -25,7 +25,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute
      * @param \Magento\Framework\Cache\FrontendInterface $attributeLabelCache
      * @param \Magento\Framework\Registry $coreRegistry
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
@@ -33,7 +33,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product\Attribute
         \Magento\Framework\Cache\FrontendInterface $attributeLabelCache,
         \Magento\Framework\Registry $coreRegistry,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $attributeLabelCache, $coreRegistry, $resultPageFactory);
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
index da0208cf65a10a4857df5fdc2dc206d007b7b8f3..507f86a2673ce96ccfc4c3399d31aba7ba4727b7 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
@@ -11,17 +11,17 @@ use Magento\Framework\App\Filesystem\DirectoryList;
 class Upload extends \Magento\Backend\App\Action
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -36,7 +36,7 @@ class Upload extends \Magento\Backend\App\Action
     }
 
     /**
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php
index 68b77495dda89e6769437d5010e06e2ffc7f981a..5c69eeaf87b0b19ae9206456fa12b1330c7f53eb 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Save.php
@@ -19,7 +19,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set
     protected $resultRedirectFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -28,14 +28,14 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Product\Set
      * @param \Magento\Framework\Registry $coreRegistry
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
         \Magento\Framework\View\LayoutFactory $layoutFactory,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context, $coreRegistry);
         $this->layoutFactory = $layoutFactory;
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php
index 45ca2a12df79d7fe537adf197ade35045c146cdc..6b60c4f74810fc5cc445384205066ba752efe4a5 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestAttributes.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product;
 class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $productBuilder);
@@ -38,7 +38,7 @@ class SuggestAttributes extends \Magento\Catalog\Controller\Adminhtml\Product
     /**
      * Search for attributes by part of attribute's label in admin store
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php
index 5e883b9f85f0d4e8132a38090556c1e06a59b5f3..72a29b9183088a4f3329ab8054b93d583f2f2286 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/SuggestProductTemplates.php
@@ -9,7 +9,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Product;
 class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Product
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Prod
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Catalog\Controller\Adminhtml\Product\Builder $productBuilder,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         parent::__construct($context, $productBuilder);
@@ -38,7 +38,7 @@ class SuggestProductTemplates extends \Magento\Catalog\Controller\Adminhtml\Prod
     /**
      * Action for product template selector
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php
old mode 100644
new mode 100755
index e22d3b2dcd39a2a8ad3138842d69d418ff8df874..40fb55c7a6626723e2ecd66afe8a16a3f36fb860
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php
@@ -27,7 +27,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product
     protected $productValidator;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -44,7 +44,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product
      * @param Builder $productBuilder
      * @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
      * @param \Magento\Catalog\Model\Product\Validator $productValidator
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      * @param \Magento\Catalog\Model\ProductFactory $productFactory
      */
@@ -53,7 +53,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product
         Product\Builder $productBuilder,
         \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
         \Magento\Catalog\Model\Product\Validator $productValidator,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory,
         \Magento\Catalog\Model\ProductFactory $productFactory
     ) {
@@ -68,7 +68,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product
     /**
      * Validate product
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.NPathComplexity)
      */
diff --git a/app/code/Magento/Catalog/Helper/Product/Composite.php b/app/code/Magento/Catalog/Helper/Product/Composite.php
index 38dc682a4c4ad41264446792c3da7d1aafe40d8d..971d6c6b10de0be0702ade569305c64f53adc400 100644
--- a/app/code/Magento/Catalog/Helper/Product/Composite.php
+++ b/app/code/Magento/Catalog/Helper/Product/Composite.php
@@ -145,7 +145,7 @@ class Composite extends \Magento\Framework\App\Helper\AbstractHelper
     {
         try {
             if (!$configureResult->getOk()) {
-                throw new \Magento\Framework\Exception\LocalizedException($configureResult->getMessage());
+                throw new \Magento\Framework\Exception\LocalizedException(__($configureResult->getMessage()));
             }
 
             $currentStoreId = (int)$configureResult->getCurrentStoreId();
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 38261678195d2dc4f1041cd0dc1dbb0b5be0747a..88e82011381c2b1e6a929a191fe2bef1c620d1b6 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -356,7 +356,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
                     'Sorry, but we can\'t move the category because we can\'t find the new parent category you'
                     . ' selected.'
                 ),
-                [],
                 $e
             );
         }
diff --git a/app/code/Magento/Catalog/Model/CategoryLinkRepository.php b/app/code/Magento/Catalog/Model/CategoryLinkRepository.php
index 771c54e46518e565848eb15271b5d54bac7517fc..3b407ed5d4b8d9553368ebbb3527516930985639 100644
--- a/app/code/Magento/Catalog/Model/CategoryLinkRepository.php
+++ b/app/code/Magento/Catalog/Model/CategoryLinkRepository.php
@@ -47,12 +47,12 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit
             $category->save();
         } catch (\Exception $e) {
             throw new CouldNotSaveException(
-                'Could not save product "%product_id" with position %position to category %category_id',
-                [
-                    'product_id' => $product->getId(),
-                    'position' => $productLink->getPosition(),
-                    'category_id' => $category->getId()
-                ],
+                __(
+                    'Could not save product "%1" with position %2 to category %3',
+                    $product->getId(),
+                    $productLink->getPosition(),
+                    $category->getId()
+                ),
                 $e
             );
         }
@@ -78,7 +78,7 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit
 
         $productID = $product->getId();
         if (!isset($productPositions[$productID])) {
-            throw new InputException('Category does not contain specified product');
+            throw new InputException(__('Category does not contain specified product'));
         }
         unset($productPositions[$productID]);
 
@@ -87,11 +87,11 @@ class CategoryLinkRepository implements \Magento\Catalog\Api\CategoryLinkReposit
             $category->save();
         } catch (\Exception $e) {
             throw new CouldNotSaveException(
-                'Could not save product "%product_id" with position %position to category %category_id',
-                [
-                    'product_id' => $product->getId(),
-                    'category_id' => $category->getId()
-                ],
+                __(
+                    'Could not save product "%1" with position %position to category %2',
+                    $product->getId(),
+                    $category->getId()
+                ),
                 $e
             );
         }
diff --git a/app/code/Magento/Catalog/Model/CategoryRepository.php b/app/code/Magento/Catalog/Model/CategoryRepository.php
index d436d06561d816dcce4695013d54b3f566eb575a..6fdba349dd044588c29d85c50372ecf815aa407b 100644
--- a/app/code/Magento/Catalog/Model/CategoryRepository.php
+++ b/app/code/Magento/Catalog/Model/CategoryRepository.php
@@ -87,7 +87,13 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter
             $this->validateCategory($category);
             $this->categoryResource->save($category);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save category: %message', ['message' => $e->getMessage()], $e);
+            throw new CouldNotSaveException(
+                __(
+                    'Could not save category: %1',
+                    $e->getMessage()
+                ),
+                $e
+            );
         }
         unset($this->instances[$category->getId()]);
         return $category;
@@ -123,10 +129,10 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter
             $this->categoryResource->delete($category);
         } catch (\Exception $e) {
             throw new StateException(
-                'Cannot delete category with id %category_id',
-                [
-                    'category_id' => $category->getId()
-                ],
+                __(
+                    'Cannot delete category with id %1',
+                    $category->getId()
+                ),
                 $e
             );
         }
@@ -168,7 +174,7 @@ class CategoryRepository implements \Magento\Catalog\Api\CategoryRepositoryInter
                         __('Attribute "%1" is required.', $attribute)
                     );
                 } else {
-                    throw new \Magento\Framework\Exception\LocalizedException($error);
+                    throw new \Magento\Framework\Exception\LocalizedException(__($error));
                 }
             }
         }
diff --git a/app/code/Magento/Catalog/Model/Entity/Attribute.php b/app/code/Magento/Catalog/Model/Entity/Attribute.php
index 5ff035d22422267e50f777df8a92e41b38bf6e8d..da907bde71f75ca5ef9f2147cfc89c3070ef8c41 100644
--- a/app/code/Magento/Catalog/Model/Entity/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Entity/Attribute.php
@@ -146,7 +146,7 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute
         try {
             $this->attrLockValidator->validate($this);
         } catch (\Magento\Framework\Exception\LocalizedException $exception) {
-            throw new \Magento\Eav\Exception($exception->getMessage());
+            throw new \Magento\Eav\Exception(__($exception->getMessage()));
         }
 
         $this->setData('modulePrefix', self::MODULE_NAME);
diff --git a/app/code/Magento/Catalog/Model/Factory.php b/app/code/Magento/Catalog/Model/Factory.php
index 5b2298df6a968da6df47bee345d9dd4c434a07fe..96ce8f0b5bc45c89acaa4b1e72057554c1849a88 100644
--- a/app/code/Magento/Catalog/Model/Factory.php
+++ b/app/code/Magento/Catalog/Model/Factory.php
@@ -43,7 +43,9 @@ class Factory
         $model = $this->_objectManager->create($className, $data);
 
         if (!$model instanceof \Magento\Framework\Model\AbstractModel) {
-            throw new \Magento\Framework\Exception\LocalizedException($className . ' doesn\'t extends \Magento\Framework\Model\AbstractModel');
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('%1 doesn\'t extends \Magento\Framework\Model\AbstractModel', $className)
+            );
         }
         return $model;
     }
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php
index b42b312614673a13667ffef2ee9a5a184fceadaa..9860c748d27cdb5fd662e9c76bf7ef120186fc41 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Full.php
@@ -28,7 +28,7 @@ class Full extends \Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction
                 $this->_reindex($store->getId());
             }
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\LocalizedException($e->getMessage(), [], $e);
+            throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()), $e);
         }
         return $this;
     }
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
index c06d8fc97ad563567e80c00559f190865fba2fc4..9d9170cd291ce83fdf3ea5649c332686f96c8a1c 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
@@ -113,9 +113,9 @@ class FlatTableBuilder
         if ($maxIndex && count($indexesNeed) > $maxIndex) {
             throw new \Magento\Framework\Exception\LocalizedException(
                 __(
-                    "The Flat Catalog module has a limit of %2\$d filterable and/or sortable attributes." .
-                    "Currently there are %1\$d of them." .
-                    "Please reduce the number of filterable/sortable attributes in order to use this module",
+                    'The Flat Catalog module has a limit of %2$d filterable and/or sortable attributes.'
+                    . 'Currently there are %1$d of them.'
+                    . 'Please reduce the number of filterable/sortable attributes in order to use this module',
                     count($indexesNeed),
                     $maxIndex
                 )
diff --git a/app/code/Magento/Catalog/Model/Layer.php b/app/code/Magento/Catalog/Model/Layer.php
index 2373865b0182f41d5c4c9db43be0d72684cd10a9..38bdfaa7b4772ddc527576a701e4999386cc7f92 100644
--- a/app/code/Magento/Catalog/Model/Layer.php
+++ b/app/code/Magento/Catalog/Model/Layer.php
@@ -217,7 +217,7 @@ class Layer extends \Magento\Framework\Object
             try {
                 $category = $this->categoryRepository->get($category);
             } catch (NoSuchEntityException $e) {
-                throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the category.'), [], $e);
+                throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the category.'), $e);
             }
         } elseif ($category instanceof \Magento\Catalog\Model\Category) {
             if (!$category->getId()) {
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php b/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php
index 9339907d04faeb7f9151b4688d4775b9d3c90a28..ac27484c3bd3ed522833ed11261bfbf0cad7e1d5 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Dynamic/AlgorithmFactory.php
@@ -67,7 +67,7 @@ class AlgorithmFactory
         $calculationType = $this->scopeConfig->getValue(self::XML_PATH_RANGE_CALCULATION, ScopeInterface::SCOPE_STORE);
 
         if (!isset($this->algorithms[$calculationType])) {
-            throw new LocalizedException($calculationType . ' was not found in algorithms');
+            throw new LocalizedException(__('%1 was not found in algorithms', $calculationType));
         }
 
         $className = $this->algorithms[$calculationType];
@@ -75,7 +75,7 @@ class AlgorithmFactory
 
         if (!$model instanceof AlgorithmInterface) {
             throw new LocalizedException(
-                $className . ' doesn\'t extends \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmInterface'
+                __('%1 doesn\'t extend \Magento\Catalog\Model\Layer\Filter\Dynamic\AlgorithmInterface', $className)
             );
         }
 
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php
index fd09131faeb9cbe55fdf7100d9a82a828779f0e0..a86c970d74a3be98c532ce59dc78177c7f07a873 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Factory.php
@@ -42,7 +42,7 @@ class Factory
 
         if (!$filter instanceof \Magento\Catalog\Model\Layer\Filter\AbstractFilter) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                $className . ' doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter'
+                __('%1 doesn\'t extends \Magento\Catalog\Model\Layer\Filter\AbstractFilter', $className)
             );
         }
         return $filter;
diff --git a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php
index 70977d63008307aedd4bd7ce2d5dca57648f3172..3ac15cc5cd688738d9bd9c257a7000cdd8ebd36f 100644
--- a/app/code/Magento/Catalog/Model/Layer/Filter/Item.php
+++ b/app/code/Magento/Catalog/Model/Layer/Filter/Item.php
@@ -56,7 +56,9 @@ class Item extends \Magento\Framework\Object
     {
         $filter = $this->getData('filter');
         if (!is_object($filter)) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('The filter must be an object. Please set correct filter.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('The filter must be an object. Please set correct filter.')
+            );
         }
         return $filter;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
index ac0c1a12a19a3c58986f463dbe8e2e40ea4a4f67..f5337a699139fe3e6e8c46aa007be00b7c738355 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
@@ -161,7 +161,7 @@ abstract class AbstractGroupPrice extends Price
                 )
             );
             if (isset($duplicates[$compare])) {
-                throw new \Magento\Framework\Exception\LocalizedException($this->_getDuplicateErrorMessage());
+                throw new \Magento\Framework\Exception\LocalizedException(__($this->_getDuplicateErrorMessage()));
             }
 
             if (!preg_match('/^\d*(\.|,)?\d{0,4}$/i', $priceRow['price']) || $priceRow['price'] < 0) {
@@ -209,7 +209,7 @@ abstract class AbstractGroupPrice extends Price
             $websiteCurrency = $rates[$priceRow['website_id']]['code'];
 
             if ($baseCurrency == $websiteCurrency && isset($duplicates[$globalCompare])) {
-                throw new \Magento\Framework\Exception\LocalizedException($this->_getDuplicateErrorMessage());
+                throw new \Magento\Framework\Exception\LocalizedException(__($this->_getDuplicateErrorMessage()));
             }
         }
 
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php
index 6c639d2a2a09204a5a7cd9f820df2cf257a5c02d..9d3dcc266bc10aa9b1b33325342120fc5e0ee3d8 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/OptionManagement.php
@@ -53,7 +53,7 @@ class OptionManagement implements \Magento\Catalog\Api\ProductAttributeOptionMan
     public function delete($attributeCode, $optionId)
     {
         if (empty($optionId)) {
-            throw new InputException(sprintf('Invalid option id %s', $optionId));
+            throw new InputException(__('Invalid option id %1', $optionId));
         }
 
         return $this->eavOptionManagement->delete(
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php
index 12fd5d96014888f3c0ac2e878c961af0cd946261..c58f0d053d574cc0a8c7d8105de4ea693a33c742 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetManagement.php
@@ -64,10 +64,14 @@ class SetManagement implements \Magento\Catalog\Api\AttributeSetManagementInterf
             $skeletonSet = $this->attributeSetRepository->get($skeletonId);
             $productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
             if ($skeletonSet->getEntityTypeId() != $productEntityId) {
-                throw new StateException('Can not create attribute set based on non product attribute set.');
+                throw new StateException(
+                    __('Can not create attribute set based on non product attribute set.')
+                );
             }
         } catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
-            throw new StateException('Can not create attribute set based on not existing attribute set');
+            throw new StateException(
+                __('Can not create attribute set based on not existing attribute set')
+            );
         }
     }
 }
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php
index 372cda91ef3bc9f08f5a297888b98d51fcca04a5..1ff9a50bea62cdfaf3a73887e9a68b6be4fdffea 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/SetRepository.php
@@ -115,7 +115,9 @@ class SetRepository implements \Magento\Catalog\Api\AttributeSetRepositoryInterf
     {
         $productEntityId = $this->eavConfig->getEntityType(\Magento\Catalog\Model\Product::ENTITY)->getId();
         if ($attributeSet->getEntityTypeId() != $productEntityId) {
-            throw new \Magento\Framework\Exception\StateException('Provided Attribute set non product Attribute set.');
+            throw new \Magento\Framework\Exception\StateException(
+                __('Provided Attribute set non product Attribute set.')
+            );
         }
     }
 }
diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php b/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php
index f546ff90b9ebef3c6d715d85da3d616cdac97c3e..c067da69a5b803a1f3f4c22ca79d37984cae4c2c 100644
--- a/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php
+++ b/app/code/Magento/Catalog/Model/Product/Gallery/ContentValidator.php
@@ -46,18 +46,18 @@ class ContentValidator
     {
         $fileContent = @base64_decode($entryContent->getEntryData(), true);
         if (empty($fileContent)) {
-            throw new InputException('The image content must be valid base64 encoded data.');
+            throw new InputException(__('The image content must be valid base64 encoded data.'));
         }
         $imageProperties = @getimagesizefromstring($fileContent);
         if (empty($imageProperties)) {
-            throw new InputException('The image content must be valid base64 encoded data.');
+            throw new InputException(__('The image content must be valid base64 encoded data.'));
         }
         $sourceMimeType = $imageProperties['mime'];
         if ($sourceMimeType != $entryContent->getMimeType() || !$this->isMimeTypeValid($sourceMimeType)) {
-            throw new InputException('The image MIME type is not valid or not supported.');
+            throw new InputException(__('The image MIME type is not valid or not supported.'));
         }
         if (!$this->isNameValid($entryContent->getName())) {
-            throw new InputException('Provided image name contains forbidden characters.');
+            throw new InputException(__('Provided image name contains forbidden characters.'));
         }
         return true;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
index f161a7d4ad56c28923853c37029afea0658a3ee2..1ed06f39bfa84a452223218604b8006f9c7b0569 100644
--- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
@@ -127,7 +127,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         if (!isset($attributes['media_gallery'])
             || !($attributes['media_gallery'] instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute)
         ) {
-            throw new StateException('Requested product does not support images.');
+            throw new StateException(__('Requested product does not support images.'));
         }
         /** @var $galleryAttribute \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */
         $galleryAttribute = $attributes['media_gallery'];
@@ -158,14 +158,14 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         try {
             $this->storeManager->getStore($product->getStoreId());
         } catch (\Exception $exception) {
-            throw new NoSuchEntityException('There is no store with provided ID.');
+            throw new NoSuchEntityException(__('There is no store with provided ID.'));
         }
         /** @var $entry ProductAttributeMediaGalleryEntryInterface */
         $entry = $product->getCustomAttribute('media_gallery')->getValue();
         $entryContent = $entry->getContent();
 
         if (!$this->contentValidator->isValid($entryContent)) {
-            throw new InputException('The image content is not valid.');
+            throw new InputException(__('The image content is not valid.'));
         }
         $product = $this->productRepository->get($product->getSku());
 
@@ -201,7 +201,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         try {
             $this->productRepository->save($product);
         } catch (\Exception $e) {
-            throw new StateException('Cannot save product.');
+            throw new StateException(__('Cannot save product.'));
         }
         // Remove all temporary files
         $mediaDirectory->delete($relativeFilePath);
@@ -220,14 +220,14 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         try {
             $this->storeManager->getStore($storeId);
         } catch (\Exception $exception) {
-            throw new NoSuchEntityException('There is no store with provided ID.');
+            throw new NoSuchEntityException(__('There is no store with provided ID.'));
         }
         $product = $this->productRepository->get($sku);
         /** @var $productMediaGallery \Magento\Catalog\Model\Product\Attribute\Backend\Media */
         $productMediaGallery = $this->getGalleryAttributeBackend($product);
         $filePath = $this->entryResolver->getEntryFilePathById($product, $entry->getId());
         if (is_null($filePath)) {
-            throw new NoSuchEntityException('There is no image with provided ID.');
+            throw new NoSuchEntityException(__('There is no image with provided ID.'));
         }
 
         $productMediaGallery->updateImage(
@@ -246,7 +246,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         try {
             $this->productRepository->save($product);
         } catch (\Exception $exception) {
-            throw new StateException('Cannot save product.');
+            throw new StateException(__('Cannot save product.'));
         }
         return true;
     }
@@ -261,7 +261,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         $productMediaGallery = $this->getGalleryAttributeBackend($product);
         $filePath = $this->entryResolver->getEntryFilePathById($product, $entryId);
         if (is_null($filePath)) {
-            throw new NoSuchEntityException('There is no image with provided ID.');
+            throw new NoSuchEntityException(__('There is no image with provided ID.'));
         }
 
         $productMediaGallery->removeImage($product, $filePath);
@@ -277,7 +277,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         try {
             $product = $this->productRepository->get($sku);
         } catch (\Exception $exception) {
-            throw new NoSuchEntityException("Such product doesn't exist");
+            throw new NoSuchEntityException(__('Such product doesn\'t exist'));
         }
 
         $output = null;
@@ -296,7 +296,7 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         }
 
         if (is_null($output)) {
-            throw new NoSuchEntityException("Such image doesn't exist");
+            throw new NoSuchEntityException(__('Such image doesn\'t exist'));
         }
         return $output;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php b/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php
index 0e689e4b69e3f4fe4c5eedbd04e6c19f413e306c..9dca54ee7ebd52fc62098ff3ab77c67f21eac864 100644
--- a/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/GroupPriceManagement.php
@@ -75,7 +75,7 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana
     public function add($sku, $customerGroupId, $price)
     {
         if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($price, 'Float')) {
-            throw new InputException('Please provide valid data');
+            throw new InputException(__('Please provide valid data'));
         }
         $customerGroup = $this->groupRepository->getById($customerGroupId);
         $product = $this->productRepository->get($sku, true);
@@ -108,13 +108,13 @@ class GroupPriceManagement implements \Magento\Catalog\Api\ProductGroupPriceMana
         if (is_array($errors) && count($errors)) {
             $errorAttributeCodes = implode(', ', array_keys($errors));
             throw new InputException(
-                sprintf('Values of following attributes are invalid: %s', $errorAttributeCodes)
+                __('Values of following attributes are invalid: %1', $errorAttributeCodes)
             );
         }
         try {
             $this->productRepository->save($product);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save group price');
+            throw new CouldNotSaveException(__('Could not save group price'));
         }
         return true;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Repository.php b/app/code/Magento/Catalog/Model/Product/Option/Repository.php
index e23481aafe81bbb6da8bacd42f4a7f60fdbe8d38..4d5103958d55dc2828b4350716a48ce0a0f94981 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Repository.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Repository.php
@@ -97,7 +97,7 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn
         try {
             $this->productRepository->save($product, true);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save product option');
+            throw new CouldNotSaveException(__('Could not save product option'));
         }
 
         $product = $this->productRepository->get($sku, true);
@@ -106,7 +106,7 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn
 
             $newID = array_diff(array_keys($currentOptions), array_keys($existingOptions));
             if (empty($newID)) {
-                throw new CouldNotSaveException('Could not save product option');
+                throw new CouldNotSaveException(__('Could not save product option'));
             }
             $newID = current($newID);
         } else {
@@ -134,7 +134,7 @@ class Repository implements \Magento\Catalog\Api\ProductCustomOptionRepositoryIn
                 $this->productRepository->save($product);
             }
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not remove custom option');
+            throw new CouldNotSaveException(__('Could not remove custom option'));
         }
         return true;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
index 2ecf3b8eb659eac7c66d3ebbf6a771466ec18480..3074ed6fdf26e803747f172091c3508b90496908 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
@@ -239,7 +239,9 @@ class DefaultType extends \Magento\Framework\Object
         if ($this->getIsValid()) {
             return $this->getUserValue();
         }
-        throw new LocalizedException(__('We couldn\'t add the product to the cart because of an option validation issue.'));
+        throw new LocalizedException(
+            __('We couldn\'t add the product to the cart because of an option validation issue.')
+        );
     }
 
     /**
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php
index ea5440461e9e7dca11f81d654cf02780e15dc53e..55f5ef434ab21d916f4a8b3d02e616c227c415e5 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Factory.php
@@ -42,7 +42,7 @@ class Factory
 
         if (!$option instanceof \Magento\Catalog\Model\Product\Option\Type\DefaultType) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType'
+                __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Option\Type\DefaultType', $className)
             );
         }
         return $option;
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
index d89d038144e44b449eaf3430baf382525207da13..b68f8f1bec8e78078d3e9601d11139dd15fcb1d9 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File.php
@@ -224,7 +224,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
             $this->setUserValue($value);
         } catch (\Magento\Framework\Exception\File\LargeSizeException $largeSizeException) {
             $this->setIsValid(false);
-            throw new LocalizedException($largeSizeException->getMessage());
+            throw new LocalizedException(__($largeSizeException->getMessage()));
         } catch (ProductException $e) {
             switch ($this->getProcessMode()) {
                 case \Magento\Catalog\Model\Product\Type\AbstractType::PROCESS_MODE_FULL:
@@ -234,16 +234,16 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
                     $this->setUserValue(null);
                     break;
             }
-        } catch (\Magento\Framework\Validator\ValidatorException $e) {
+        } catch (\Magento\Framework\Validator\Exception $e) {
             $this->setUserValue(null);
         } catch (\Magento\Framework\Exception\File\ValidatorException $e) {
             $this->setIsValid(false);
-            throw new LocalizedException($e->getMessage());
+            throw new LocalizedException(__($e->getMessage()));
         } catch (\Exception $e) {
             if ($this->getSkipCheckRequiredOption()) {
                 $this->setUserValue(null);
             } else {
-                throw new LocalizedException($e->getMessage());
+                throw new LocalizedException(__($e->getMessage()));
             }
         }
         return $this;
@@ -341,7 +341,7 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
                 $sizes
             );
         } catch (\Exception $e) {
-            throw new LocalizedException(__("The file options format is not valid."));
+            throw new LocalizedException(__('The file options format is not valid.'));
         }
     }
 
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
index 5bdcebfbe9b1b41e31728fee08067265fe038858..2338b3ca6ea9822c8ebcd7d095c140ac4ee7f6e4 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php
@@ -91,7 +91,7 @@ class ValidatorFile extends Validator
      * @return array
      * @throws \Magento\Framework\Exception\LocalizedException
      * @throws \Zend_File_Transfer_Exception
-     * @throws \Magento\Framework\Validator\ValidatorException
+     * @throws \Magento\Framework\Validator\Exception
      * @throws \Magento\Catalog\Model\Product\Exception
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -103,21 +103,21 @@ class ValidatorFile extends Validator
         try {
             $runValidation = $option->getIsRequire() || $upload->isUploaded($file);
             if (!$runValidation) {
-                throw new \Magento\Framework\Validator\ValidatorException(
+                throw new \Magento\Framework\Validator\Exception(
                     __('Validation failed. Required options were not filled or file was not uploaded.')
                 );
             }
 
             $fileInfo = $upload->getFileInfo($file)[$file];
             $fileInfo['title'] = $fileInfo['name'];
-        } catch (\Magento\Framework\Validator\ValidatorException $e) {
+        } catch (\Magento\Framework\Validator\Exception $e) {
             throw $e;
         } catch (\Exception $e) {
             // when file exceeds the upload_max_filesize, $_FILES is empty
             if ($this->validateContentLength()) {
                 $value = $this->fileSize->getMaxFileSizeInMb();
                 throw new \Magento\Framework\Exception\File\LargeSizeException(
-                    __("The file you uploaded is larger than %1 Megabytes allowed by server", $value)
+                    __('The file you uploaded is larger than %1 Megabytes allowed by server', $value)
                 );
             } else {
                 throw new ProductException(__('Option required.'));
@@ -188,7 +188,7 @@ class ValidatorFile extends Validator
             $errors = $this->getValidatorErrors($upload->getErrors(), $fileInfo, $option);
 
             if (count($errors) > 0) {
-                throw new \Magento\Framework\Exception\File\ValidatorException(implode("\n", $errors));
+                throw new \Magento\Framework\Exception\File\ValidatorException(__(implode("\n", $errors)));
             }
         } else {
             throw new \Magento\Framework\Exception\File\ValidatorException(
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php
index 8e9a92be8bb1f6664cee0ac0cc5c2f6bf2dd6a74..373b8a63db3fe28bce01645bd8eb36bd5d9ae406 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfo.php
@@ -98,7 +98,7 @@ class ValidatorInfo extends Validator
             $errors = $this->getValidatorErrors($validatorChain->getErrors(), $optionValue, $option);
 
             if (count($errors) > 0) {
-                throw new \Magento\Framework\Exception\LocalizedException(implode("\n", $errors));
+                throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors)));
             }
         } else {
             throw new \Magento\Framework\Exception\LocalizedException(
diff --git a/app/code/Magento/Catalog/Model/Product/PriceModifier.php b/app/code/Magento/Catalog/Model/Product/PriceModifier.php
index 56db5467cbe53959b691c05befeac43498e598c2..d4a2403fbbfe75250e62112f298167b3001def4c 100644
--- a/app/code/Magento/Catalog/Model/Product/PriceModifier.php
+++ b/app/code/Magento/Catalog/Model/Product/PriceModifier.php
@@ -37,7 +37,7 @@ class PriceModifier
     {
         $prices = $product->getData('group_price');
         if (is_null($prices)) {
-            throw new NoSuchEntityException("This product doesn't have group price");
+            throw new NoSuchEntityException(__('This product doesn\'t have group price'));
         }
         $groupPriceQty = count($prices);
 
@@ -50,15 +50,17 @@ class PriceModifier
         }
         if ($groupPriceQty == count($prices)) {
             throw new NoSuchEntityException(
-                "Product hasn't group price with such data: customerGroupId = '$customerGroupId',"
-                . "website = $websiteId."
+                __(
+                    'Product hasn\'t group price with such data: customerGroupId = \'%1\', website = %2.',
+                    [$customerGroupId, $websiteId]
+                )
             );
         }
         $product->setData('group_price', $prices);
         try {
             $this->productRepository->save($product);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException("Invalid data provided for group price");
+            throw new CouldNotSaveException(__('Invalid data provided for group price'));
         }
     }
 
@@ -77,7 +79,7 @@ class PriceModifier
         $prices = $product->getData('tier_price');
         // verify if price exist
         if (is_null($prices)) {
-            throw new NoSuchEntityException("This product doesn't have tier price");
+            throw new NoSuchEntityException(__('This product doesn\'t have tier price'));
         }
         $tierPricesQty = count($prices);
 
@@ -95,15 +97,18 @@ class PriceModifier
 
         if ($tierPricesQty == count($prices)) {
             throw new NoSuchEntityException(
-                "Product hasn't group price with such data: customerGroupId = '$customerGroupId',"
-                . "website = $websiteId, qty = $qty"
+                __(
+                    'Product hasn\'t group price with such data: customerGroupId = \'%1\''
+                    . ', website = %2, qty = %3',
+                    [$customerGroupId, $websiteId, $qty]
+                )
             );
         }
         $product->setData('tier_price', $prices);
         try {
             $this->productRepository->save($product);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException("Invalid data provided for tier_price");
+            throw new CouldNotSaveException(__('Invalid data provided for tier_price'));
         }
     }
 }
diff --git a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php
index 0c0ed5d54b4e74cdca2369ae9f27a91a10490b2c..73ae4f96ea9becf98147146a80eb2b87286b2695 100644
--- a/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/TierPriceManagement.php
@@ -88,7 +88,7 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage
     public function add($sku, $customerGroupId, $price, $qty)
     {
         if (!\Zend_Validate::is($price, 'Float') || $price <= 0 || !\Zend_Validate::is($qty, 'Float') || $qty <= 0) {
-            throw new InputException('Please provide valid data');
+            throw new InputException(__('Please provide valid data'));
         }
         $product = $this->productRepository->get($sku, ['edit_mode' => true]);
         $tierPrices = $product->getData('tier_price');
@@ -131,13 +131,13 @@ class TierPriceManagement implements \Magento\Catalog\Api\ProductTierPriceManage
         if (is_array($errors) && count($errors)) {
             $errorAttributeCodes = implode(', ', array_keys($errors));
             throw new InputException(
-                sprintf('Values of following attributes are invalid: %s', $errorAttributeCodes)
+                __('Values of following attributes are invalid: %1', $errorAttributeCodes)
             );
         }
         try {
             $this->productRepository->save($product);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not save group price');
+            throw new CouldNotSaveException(__('Could not save group price'));
         }
         return true;
     }
diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
index fe9863c9f2cb1703c491fb7673a273b58350ea6c..2a59073ff7f5fb5cca087f9a331c2fd48c7fa013 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
@@ -503,7 +503,7 @@ abstract class AbstractType
                             if (isset($queueOptions['option'])) {
                                 $queueOptions['option']->setIsValid(false);
                             }
-                            throw new \Magento\Framework\Exception\LocalizedException(__("The file upload failed."));
+                            throw new \Magento\Framework\Exception\LocalizedException(__('The file upload failed.'));
                         }
                         $this->_fileStorageDb->saveFile($dst);
                         break;
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Pool.php b/app/code/Magento/Catalog/Model/Product/Type/Pool.php
index 05d9b00bd763dd3cbe4efc89769653abf9766110..fed0942d794009ac05cb47bbb6e543164016dcf9 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Pool.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Pool.php
@@ -42,7 +42,7 @@ class Pool
 
         if (!$product instanceof \Magento\Catalog\Model\Product\Type\AbstractType) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\AbstractType'
+                __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Type\AbstractType', $className)
             );
         }
         return $product;
diff --git a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php
index b3276c807759c711901de23f2d9acd0ff55f792b..d8015f9390d6b6da18ec4d5a470660b05b4341ae 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/Price/Factory.php
@@ -42,7 +42,7 @@ class Factory
 
         if (!$price instanceof \Magento\Catalog\Model\Product\Type\Price) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                $className . ' doesn\'t extends \Magento\Catalog\Model\Product\Type\Price'
+                __('%1 doesn\'t extends \Magento\Catalog\Model\Product\Type\Price', $className)
             );
         }
         return $price;
diff --git a/app/code/Magento/Catalog/Model/Product/Website.php b/app/code/Magento/Catalog/Model/Product/Website.php
index 7782fb5bc260d88988b53b09fbb549ff063928e7..0a389baf909c6472b329f654fbd2d176724f232f 100644
--- a/app/code/Magento/Catalog/Model/Product/Website.php
+++ b/app/code/Magento/Catalog/Model/Product/Website.php
@@ -53,7 +53,9 @@ class Website extends \Magento\Framework\Model\AbstractModel
         try {
             $this->_getResource()->removeProducts($websiteIds, $productIds);
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Something went wrong removing products from the websites.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Something went wrong removing products from the websites.')
+            );
         }
         return $this;
     }
@@ -71,7 +73,9 @@ class Website extends \Magento\Framework\Model\AbstractModel
         try {
             $this->_getResource()->addProducts($websiteIds, $productIds);
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Something went wrong adding products to websites.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Something went wrong adding products to websites.')
+            );
         }
         return $this;
     }
diff --git a/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php b/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php
index 28e1c5cea9bcf6f4797727445c5d12cc5b897ce7..980843c9df25199d036cb861c225cfc5402d9f18 100644
--- a/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php
+++ b/app/code/Magento/Catalog/Model/ProductAttributeGroupRepository.php
@@ -66,7 +66,7 @@ class ProductAttributeGroupRepository implements \Magento\Catalog\Api\ProductAtt
         $group = $this->groupFactory->create();
         $this->groupResource->load($group, $groupId);
         if (!$group->getId()) {
-            throw new NoSuchEntityException(sprintf('Group with id "%s" does not exist.', $groupId));
+            throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId));
         }
         return $group;
     }
@@ -89,7 +89,9 @@ class ProductAttributeGroupRepository implements \Magento\Catalog\Api\ProductAtt
     {
         /** @var \Magento\Catalog\Model\Product\Attribute\Group $group */
         if ($group->hasSystemAttributes()) {
-            throw new StateException('Attribute group that contains system attributes can not be deleted');
+            throw new StateException(
+                __('Attribute group that contains system attributes can not be deleted')
+            );
         }
         return $this->groupRepository->delete($group);
     }
diff --git a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
index 3a744449e6f23aefa381112a6a1134deaabdcfd8..885ded02d329c339c131e06cc7e4b07d3aa9aa78 100644
--- a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
+++ b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
@@ -42,7 +42,7 @@ class CollectionProvider
     public function getCollection(\Magento\Catalog\Model\Product $product, $type)
     {
         if (!isset($this->providers[$type])) {
-            throw new NoSuchEntityException('Collection provider is not registered');
+            throw new NoSuchEntityException(__('Collection provider is not registered'));
         }
 
         $products = $this->providers[$type]->getLinkedProducts($product);
diff --git a/app/code/Magento/Catalog/Model/ProductLink/Management.php b/app/code/Magento/Catalog/Model/ProductLink/Management.php
index 2987ebc079a4bb954b2c3de90b670b99dc7198d5..558561d22de50af6f402f9201a6138aaba441496 100644
--- a/app/code/Magento/Catalog/Model/ProductLink/Management.php
+++ b/app/code/Magento/Catalog/Model/ProductLink/Management.php
@@ -77,7 +77,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface
         try {
             $collection = $this->entityCollectionProvider->getCollection($product, $type);
         } catch (NoSuchEntityException $e) {
-            throw new NoSuchEntityException('Unknown link type: ' . (string)$type);
+            throw new NoSuchEntityException(__('Unknown link type: %1', (string)$type));
         }
         foreach ($collection as $item) {
             /** @var \Magento\Catalog\Api\Data\ProductLinkInterface $productLink */
@@ -106,7 +106,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface
 
         if (!isset($linkTypes[$type])) {
             throw new NoSuchEntityException(
-                sprintf("Provided link type \"%s\" does not exist", $type)
+                __('Provided link type "%1" does not exist', $type)
             );
         }
 
@@ -125,7 +125,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface
             $linkedSku = $link->getLinkedProductSku();
             if (!isset($linkedProductIds[$linkedSku])) {
                 throw new NoSuchEntityException(
-                    sprintf("Product with SKU \"%s\" does not exist", $linkedSku)
+                    __('Product with SKU "%1" does not exist', $linkedSku)
                 );
             }
             $data['product_id'] = $linkedProductIds[$linkedSku];
@@ -135,7 +135,7 @@ class Management implements \Magento\Catalog\Api\ProductLinkManagementInterface
         try {
             $product->save();
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException('Invalid data provided for linked products');
+            throw new CouldNotSaveException(__('Invalid data provided for linked products'));
         }
         return true;
     }
diff --git a/app/code/Magento/Catalog/Model/ProductLink/Repository.php b/app/code/Magento/Catalog/Model/ProductLink/Repository.php
index 386e7e8bb4d880942eed3f14ed575bd7b1eb3a49..282d14bb2c243d74792c7ed4e647af56812bcfcf 100644
--- a/app/code/Magento/Catalog/Model/ProductLink/Repository.php
+++ b/app/code/Magento/Catalog/Model/ProductLink/Repository.php
@@ -85,7 +85,7 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface
         try {
             $product->save();
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException('Invalid data provided for linked products');
+            throw new CouldNotSaveException(__('Invalid data provided for linked products'));
         }
         return true;
     }
@@ -101,8 +101,8 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface
 
         if (!isset($links[$linkedProduct->getId()])) {
             throw new NoSuchEntityException(
-                sprintf(
-                    'Product with SKU %s is not linked to product with SKU %s',
+                __(
+                    'Product with SKU %1 is not linked to product with SKU %2',
                     $entity->getLinkedProductSku(),
                     $entity->getProductSku()
                 )
@@ -115,7 +115,7 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface
         try {
             $product->save();
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException('Invalid data provided for linked products');
+            throw new CouldNotSaveException(__('Invalid data provided for linked products'));
         }
         return true;
     }
@@ -133,12 +133,14 @@ class Repository implements \Magento\Catalog\Api\ProductLinkRepositoryInterface
             }
         }
         throw new NoSuchEntityException(
-            'Product %s doesn\'t have linked %s as %s',
-            [
-                $sku,
-                $linkedProductSku,
-                $type
-            ]
+            __(
+                'Product %1 doesn\'t have linked %2 as %3',
+                [
+                    $sku,
+                    $linkedProductSku,
+                    $type
+                ]
+            )
         );
     }
 }
diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php
index 284f7343cc629880a54d4898fc569b02599a76ed..ae3fd0df2e6c8a4f5963957eead7caff999ba57f 100644
--- a/app/code/Magento/Catalog/Model/ProductRepository.php
+++ b/app/code/Magento/Catalog/Model/ProductRepository.php
@@ -132,7 +132,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
 
             $productId = $this->resourceModel->getIdBySku($sku);
             if (!$productId) {
-                throw new NoSuchEntityException('Requested product doesn\'t exist');
+                throw new NoSuchEntityException(__('Requested product doesn\'t exist'));
             }
             if ($editMode) {
                 $product->setData('_edit_mode', true);
@@ -161,7 +161,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
             }
             $product->load($productId);
             if (!$product->getId()) {
-                throw new NoSuchEntityException('Requested product doesn\'t exist');
+                throw new NoSuchEntityException(__('Requested product doesn\'t exist'));
             }
             $this->instancesById[$productId][$cacheKey] = $product;
             $this->instances[$product->getSku()][$cacheKey] = $product;
@@ -231,7 +231,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
         $validationResult = $this->resourceModel->validate($product);
         if (true !== $validationResult) {
             throw new \Magento\Framework\Exception\CouldNotSaveException(
-                sprintf('Invalid product data: %s', implode(',', $validationResult))
+                __('Invalid product data: %1', implode(',', $validationResult))
             );
         }
         try {
@@ -249,7 +249,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
                 $exception
             );
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\CouldNotSaveException('Unable to save product');
+            throw new \Magento\Framework\Exception\CouldNotSaveException(__('Unable to save product'));
         }
         unset($this->instances[$product->getSku()]);
         unset($this->instancesById[$product->getId()]);
@@ -266,7 +266,9 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa
         try {
             $this->resourceModel->delete($product);
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\StateException('Unable to remove product ' . $sku);
+            throw new \Magento\Framework\Exception\StateException(
+                __('Unable to remove product %1', $sku)
+            );
         }
         unset($this->instances[$sku]);
         unset($this->instancesById[$productId]);
diff --git a/app/code/Magento/Catalog/Model/Resource/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Attribute.php
index 31d0da053ba201b7f390b40143b3913c35708f8c..b54445ceaa95d1e48ee91becc731e0d1b344abb9 100644
--- a/app/code/Magento/Catalog/Model/Resource/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Attribute.php
@@ -132,7 +132,7 @@ class Attribute extends \Magento\Eav\Model\Resource\Entity\Attribute
                 $this->attrLockValidator->validate($attribute, $result['attribute_set_id']);
             } catch (\Magento\Framework\Exception\LocalizedException $exception) {
                 throw new \Magento\Framework\Exception\LocalizedException(
-                    __("Attribute '%1' is locked. ", $attribute->getAttributeCode()) . $exception->getMessage()
+                    __('Attribute \'%1\' is locked. %2', $attribute->getAttributeCode(), $exception->getMessage())
                 );
             }
 
diff --git a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
index 34f07aff2415de9ede946f1a30bbce63918d2f52..63b02e7e2308251a9a66f489806f2f5ef0c783e7 100644
--- a/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
+++ b/app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php
@@ -187,7 +187,9 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements
                 try {
                     $this->attrLockValidator->validate($this);
                 } catch (\Magento\Framework\Exception\LocalizedException $exception) {
-                    throw new \Magento\Framework\Exception\LocalizedException(__('Do not change the scope. ' . $exception->getMessage()));
+                    throw new \Magento\Framework\Exception\LocalizedException(
+                        __('Do not change the scope. %1', $exception->getMessage())
+                    );
                 }
             }
         }
diff --git a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php
index f91726c700c126971ed1eeb5c8be433d122df1fa..569bed1e495c6515f2ff0d3b9743ed263c62c971 100644
--- a/app/code/Magento/Catalog/Model/Template/Filter/Factory.php
+++ b/app/code/Magento/Catalog/Model/Template/Filter/Factory.php
@@ -43,7 +43,9 @@ class Factory
         $filter = $this->_objectManager->create($className, $data);
 
         if (!$filter instanceof \Magento\Framework\Filter\Template) {
-            throw new \Magento\Framework\Exception\LocalizedException($className . ' doesn\'t extends \Magento\Framework\Filter\Template');
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('%1 doesn\'t extend \Magento\Framework\Filter\Template', $className)
+            );
         }
         return $filter;
     }
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
index 94b386f8c656e9f31d8a1beb0e08d4e2d71fa73e..9b5bb8d759b6b78396f9bf4db5792c1259e3d56f 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php
@@ -22,7 +22,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase
     protected $resultRawFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactoryMock;
 
@@ -115,7 +115,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase
             false
         );
         $this->resultJsonFactoryMock = $this->getMock(
-            'Magento\Framework\Controller\Result\JSONFactory',
+            'Magento\Framework\Controller\Result\JsonFactory',
             ['create'],
             [],
             '',
@@ -350,7 +350,7 @@ class SaveTest extends \PHPUnit_Framework_TestCase
             ['getMessagesBlock']
         );
         /**
-         * @var \Magento\Framework\Controller\Result\JSON
+         * @var \Magento\Framework\Controller\Result\Json
          * |\PHPUnit_Framework_MockObject_MockObject $resultJsonMock
          */
         $resultJsonMock = $this->getMock(
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
index 5846a299d0e5573ad4468abea1722047719eaf28..26b7598e03b0f7609ea78634148aa01d4a227799 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Widget/CategoriesJsonTest.php
@@ -52,7 +52,7 @@ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase
     protected $objectManagerMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJson;
 
@@ -84,10 +84,10 @@ class CategoriesJsonTest extends \PHPUnit_Framework_TestCase
             )
         );
 
-        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->getMock();
-        $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
index 84bf8ed85a12bda25808f7b258bc33ceaf0365f7..77f31ab47a4f6636792d227686854e328e0ac3a2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/SaveTest.php
@@ -27,6 +27,9 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe
     /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */
     protected $initializationHelper;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->productBuilder = $this->getMock(
@@ -101,8 +104,9 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe
     }
 
     /**
-     * @dataProvider exceptionTypeDataProvider
      * @param string $exceptionType
+     * @return void
+     * @dataProvider exceptionTypeDataProvider
      */
     public function testExecuteSetsProductDataToSessionAndRedirectsToNewActionOnError($exceptionType)
     {
@@ -111,7 +115,7 @@ class SaveTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTe
         $this->request->expects($this->any())->method('getPostValue')->willReturn($productData);
         $this->initializationHelper->expects($this->any())->method('initialize')
             ->willReturn($this->product);
-        $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType('message'));
+        $this->product->expects($this->any())->method('getSku')->willThrowException(new $exceptionType(__('message')));
 
         $this->session->expects($this->once())->method('setProductData')->with($productData);
         $this->resultRedirect->expects($this->once())->method('setPath')->with('catalog/*/new');
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
index 4fcdb62579697612abcce7d2a2e6dc79ce800b16..ed28dc6fda78135af0e50f4e57d7db7c656dac67 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductLink/ManagementTest.php
@@ -158,7 +158,7 @@ class ManagementTest extends \PHPUnit_Framework_TestCase
         $this->collectionProviderMock->expects($this->once())
             ->method('getCollection')
             ->with($this->productMock, $linkType)
-            ->willThrowException(new NoSuchEntityException('Collection provider is not registered'));
+            ->willThrowException(new NoSuchEntityException(__('Collection provider is not registered')));
 
         $this->model->getLinkedItemsByType($productSku, $linkType);
     }
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
old mode 100644
new mode 100755
index 77a8bd953da00be195c161d932aabba938cd4985..ec50e2fcbc476c73b2a5fedbe264f782f09a2de0
--- a/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Template/Filter/FactoryTest.php
@@ -17,6 +17,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
      */
     protected $_factory;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     protected function setUp()
     {
         $this->_objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
@@ -28,6 +33,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test create
+     *
+     * @return void
+     */
     public function testCreate()
     {
         $className = 'Magento\Framework\Filter\Template';
@@ -47,6 +57,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($filterMock, $this->_factory->create($className));
     }
 
+    /**
+     * Test create with arguments
+     *
+     * @return void
+     */
     public function testCreateWithArguments()
     {
         $className = 'Magento\Framework\Filter\Template';
@@ -68,8 +83,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test wrong type exception
+     *
      * @expectedException \Magento\Framework\Exception\LocalizedException
-     * @expectedExceptionMessage WrongClass doesn't extends \Magento\Framework\Filter\Template
+     * @expectedExceptionMessage WrongClass doesn't extend \Magento\Framework\Filter\Template
+     * @return void
      */
     public function testWrongTypeException()
     {
diff --git a/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml b/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml
index c14759cdc910ec6f5c14762f917359f872a5fa86..1865f71cd6b75e56cc0ddb0fa9a979079ca56ea9 100644
--- a/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml
+++ b/app/code/Magento/Catalog/view/base/templates/product/price/amount/default.phtml
@@ -15,7 +15,7 @@
     <?php if ($block->getDisplayLabel()): ?>
         <span class="price-label"><?php echo $block->getDisplayLabel(); ?></span>
     <?php endif; ?>
-    <span<?php if ($block->getPriceId()): ?> id="<?php echo $block->getPriceId() ?>"<?php endif;?>
+    <span <?php if ($block->getPriceId()): ?> id="<?php echo $block->getPriceId() ?>"<?php endif;?>
         <?php echo($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
         data-price-amount="<?php echo $block->getDisplayValue(); ?>"
         data-price-type="<?php echo $block->getPriceType(); ?>"
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
index 0bcac43699d1cc037b309bbedc1f384f7bec0e51..e8bba488c9612ebe32cd9124212f1f5640daf127 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php
@@ -618,14 +618,14 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
             if (!($model = $this->_productTypeFactory->create($productTypeConfig['model'], ['params' => $params]))
             ) {
                 throw new \Magento\Framework\Exception\LocalizedException(
-                    __("Entity type model '%1' is not found", $productTypeConfig['model'])
+                    __('Entity type model \'%1\' is not found', $productTypeConfig['model'])
                 );
             }
             if (!$model instanceof \Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType) {
                 throw new \Magento\Framework\Exception\LocalizedException(
                     __(
-                        'Entity type model must be an instance of ' .
-                        'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType'
+                        'Entity type model must be an instance of '
+                        . 'Magento\CatalogImportExport\Model\Import\Product\Type\AbstractType'
                     )
                 );
             }
@@ -1233,7 +1233,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
             $tmpPath = $this->_mediaDirectory->getAbsolutePath('import');
             if (!$this->_fileUploader->setTmpDir($tmpPath)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
-                    __("File directory '%1' is not readable.", $tmpPath)
+                    __('File directory \'%1\' is not readable.', $tmpPath)
                 );
             }
             $destinationDir = "catalog/product";
@@ -1242,7 +1242,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
             $this->_mediaDirectory->create($destinationDir);
             if (!$this->_fileUploader->setDestDir($destinationPath)) {
                 throw new \Magento\Framework\Exception\LocalizedException(
-                    __("File directory '%1' is not writable.", $destinationPath)
+                    __('File directory \'%1\' is not writable.', $destinationPath)
                 );
             }
         }
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
index b1b556466c5e587b90357824435bad027b6ac123..1f0e83871d4f29837b390a0b992f1756134f55de 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
@@ -472,7 +472,9 @@ class Option extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
         if (isset($data['product_entity'])) {
             $this->_productEntity = $data['product_entity'];
         } else {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Option entity must have a parent product entity.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Option entity must have a parent product entity.')
+            );
         }
         if (isset($data['collection_by_pages_iterator'])) {
             $this->_byPagesIterator = $data['collection_by_pages_iterator'];
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
index d16f877a7e83e02db75601a7c5f0fb4e35c2e9b0..be21e3e2019ab885b08ed7c87ef0969175b379a9 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Type/AbstractType.php
@@ -96,13 +96,10 @@ abstract class AbstractType
         $this->_prodAttrColFac = $prodAttrColFac;
 
         if ($this->isSuitable()) {
-            if (!isset(
-                $params[0]
-            ) || !isset(
-                $params[1]
-            ) || !is_object(
-                $params[0]
-            ) || !$params[0] instanceof \Magento\CatalogImportExport\Model\Import\Product
+            if (!isset($params[0])
+                || !isset($params[1])
+                || !is_object($params[0])
+                || !$params[0] instanceof \Magento\CatalogImportExport\Model\Import\Product
             ) {
                 throw new \Magento\Framework\Exception\LocalizedException(__('Please correct the parameters.'));
             }
diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php
index d41f2951dadeab5d2c610f0609c94e5e8e1d0670..4a5cc92f8f87e9ed80554525a5394cf8e4e7bbe6 100644
--- a/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php
+++ b/app/code/Magento/CatalogInventory/Model/Stock/StockItemRepository.php
@@ -156,7 +156,7 @@ class StockItemRepository implements StockItemRepositoryInterface
 
             $this->indexProcessor->reindexRow($stockItem->getProductId());
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException($exception->getMessage());
+            throw new CouldNotSaveException(__($exception->getMessage()));
         }
         return $stockItem;
     }
@@ -169,7 +169,7 @@ class StockItemRepository implements StockItemRepositoryInterface
         $stockItem = $this->stockItemFactory->create();
         $this->resource->load($stockItem, $stockItemId);
         if (!$stockItem->getItemId()) {
-            throw new NoSuchEntityException(sprintf('Stock Item with id "%s" does not exist.', $stockItemId));
+            throw new NoSuchEntityException(__('Stock Item with id "%1" does not exist.', $stockItemId));
         }
         return $stockItem;
     }
@@ -195,7 +195,7 @@ class StockItemRepository implements StockItemRepositoryInterface
         try {
             $this->resource->delete($stockItem);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
@@ -209,7 +209,7 @@ class StockItemRepository implements StockItemRepositoryInterface
             $stockItem = $this->get($id);
             $this->delete($stockItem);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php
index bc3f7774e874cf186638f0f71f0d4ae7afd0cc60..590f98813c9049a411ee4d9395c4d377e2417afc 100644
--- a/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php
+++ b/app/code/Magento/CatalogInventory/Model/Stock/StockRepository.php
@@ -78,7 +78,7 @@ class StockRepository implements StockRepositoryInterface
         try {
             $this->resource->save($stock);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException($exception->getMessage());
+            throw new CouldNotSaveException(__($exception->getMessage()));
         }
         return $stock;
     }
@@ -93,7 +93,7 @@ class StockRepository implements StockRepositoryInterface
         $stock = $this->stockFactory->create();
         $this->resource->load($stock, $stockId);
         if (!$stock->getId()) {
-            throw new NoSuchEntityException(sprintf('Stock with id "%s" does not exist.', $stockId));
+            throw new NoSuchEntityException(__('Stock with id "%1" does not exist.', $stockId));
         }
         return $stock;
     }
@@ -122,7 +122,7 @@ class StockRepository implements StockRepositoryInterface
         try {
             $this->resource->delete($stock);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
@@ -138,7 +138,7 @@ class StockRepository implements StockRepositoryInterface
             $stock = $this->get($id);
             $this->delete($stock);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php b/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php
index 2c1e24a42c024e1f2512b2e89951be3c69d0673c..cef158fe1d44f1fd5cde737099c7d1d11fb4a80c 100644
--- a/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php
+++ b/app/code/Magento/CatalogInventory/Model/Stock/StockStatusRepository.php
@@ -76,7 +76,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface
         try {
             $this->resource->save($stockStatus);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException($exception->getMessage());
+            throw new CouldNotSaveException(__($exception->getMessage()));
         }
         return $stockStatus;
     }
@@ -116,7 +116,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface
         try {
             $this->resource->delete($stockStatus);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
@@ -132,7 +132,7 @@ class StockStatusRepository implements StockStatusRepositoryInterface
             $stockStatus = $this->get($id);
             $this->delete($stockStatus);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/CatalogInventory/Model/StockRegistry.php b/app/code/Magento/CatalogInventory/Model/StockRegistry.php
index 999a786214e17a304fcce637917f37527206d6d3..fefbf9f34899f031a374d551e390b24235d3f9c0 100644
--- a/app/code/Magento/CatalogInventory/Model/StockRegistry.php
+++ b/app/code/Magento/CatalogInventory/Model/StockRegistry.php
@@ -205,7 +205,10 @@ class StockRegistry implements StockRegistryInterface
         $productId = $product->getIdBySku($productSku);
         if (!$productId) {
             throw new \Magento\Framework\Exception\NoSuchEntityException(
-                "Product with SKU \"{$productSku}\" does not exist"
+                __(
+                    'Product with SKU "%1" does not exist',
+                    $productSku
+                )
             );
         }
         return $productId;
diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php
index be0dcc77b2cad4d271761ea1c379ddbec323f869..ead5a8829f774d7ebdfac0d3f0d190e3cea0fdd9 100644
--- a/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php
+++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Rule/JobTest.php
@@ -44,7 +44,7 @@ class JobTest extends \PHPUnit_Framework_TestCase
         );
         $exceptionMessage = 'Test exception message';
         $exceptionCallback = function () use ($exceptionMessage) {
-            throw new \Magento\Framework\Exception\LocalizedException($exceptionMessage);
+            throw new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage));
         };
         $ruleProcessorMock->expects($this->once())
             ->method('markIndexerAsInvalid')
diff --git a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php
index efb5d35dcca1e0fc8f54e20a2545187fe04a5a9c..f15ccfdede8694ac96cdd2a991ce179e232474dd 100644
--- a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php
+++ b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php
@@ -36,15 +36,15 @@ class UpdateItemOptions extends \Magento\Checkout\Controller\Cart
 
             $quoteItem = $this->cart->getQuote()->getItemById($id);
             if (!$quoteItem) {
-                throw new \Magento\Framework\Exception\LocalizedException(__("We can't find the quote item."));
+                throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the quote item.'));
             }
 
             $item = $this->cart->updateItem($id, new \Magento\Framework\Object($params));
             if (is_string($item)) {
-                throw new \Magento\Framework\Exception\LocalizedException($item);
+                throw new \Magento\Framework\Exception\LocalizedException(__($item));
             }
             if ($item->getHasError()) {
-                throw new \Magento\Framework\Exception\LocalizedException($item->getMessage());
+                throw new \Magento\Framework\Exception\LocalizedException(__($item->getMessage()));
             }
 
             $related = $this->getRequest()->getParam('related_product');
diff --git a/app/code/Magento/Checkout/Controller/Onepage.php b/app/code/Magento/Checkout/Controller/Onepage.php
index 83da6a58c07353ae9cbedbf035bad67bd67b25a2..3a47eca2e4f86807ed665c56deed717b2b89319a 100644
--- a/app/code/Magento/Checkout/Controller/Onepage.php
+++ b/app/code/Magento/Checkout/Controller/Onepage.php
@@ -77,7 +77,7 @@ class Onepage extends Action
     protected $resultRawFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -96,7 +96,7 @@ class Onepage extends Action
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -115,7 +115,7 @@ class Onepage extends Action
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         $this->_coreRegistry = $coreRegistry;
         $this->_translateInline = $translateInline;
diff --git a/app/code/Magento/Checkout/Helper/Data.php b/app/code/Magento/Checkout/Helper/Data.php
index b3a064ad8163deff1357c9644694bea307e78900..44f5950b80be6b60230d9b008b56b33a5fab7f73 100644
--- a/app/code/Magento/Checkout/Helper/Data.php
+++ b/app/code/Magento/Checkout/Helper/Data.php
@@ -278,7 +278,11 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
                 [
                     'reason' => $message,
                     'checkoutType' => $checkoutType,
-                    'dateAndTime' => $this->_localeDate->date(),
+                    'dateAndTime' => $this->_localeDate->formatDateTime(
+                        new \DateTime(),
+                        \IntlDateFormatter::MEDIUM,
+                        \IntlDateFormatter::MEDIUM
+                    ),
                     'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(),
                     'customerEmail' => $checkout->getCustomerEmail(),
                     'billingAddress' => $checkout->getBillingAddress(),
diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php
index 39b276ce099f8c11dd88c748a3ed5f49d1bee05d..69060c34e2058287cab7bbac92815ab7ff257d51 100644
--- a/app/code/Magento/Checkout/Model/Cart.php
+++ b/app/code/Magento/Checkout/Model/Cart.php
@@ -286,7 +286,7 @@ class Cart extends Object implements CartInterface
             try {
                 $product = $this->productRepository->getById($productInfo, false, $storeId);
             } catch (NoSuchEntityException $e) {
-                throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.'), [], $e);
+                throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.'), $e);
             }
         } else {
             throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t find the product.'));
@@ -372,7 +372,7 @@ class Cart extends Object implements CartInterface
                 if ($this->_checkoutSession->getUseNotice() === null) {
                     $this->_checkoutSession->setUseNotice(true);
                 }
-                throw new \Magento\Framework\Exception\LocalizedException($result);
+                throw new \Magento\Framework\Exception\LocalizedException(__($result));
             }
         } else {
             throw new \Magento\Framework\Exception\LocalizedException(__('The product does not exist.'));
@@ -502,7 +502,7 @@ class Cart extends Object implements CartInterface
                 $itemInQuote = $this->getQuote()->getItemById($item->getId());
 
                 if (!$itemInQuote && $item->getHasError()) {
-                    throw new \Magento\Framework\Exception\LocalizedException($item->getMessage());
+                    throw new \Magento\Framework\Exception\LocalizedException(__($item->getMessage()));
                 }
 
                 if (isset($itemInfo['before_suggest_qty']) && $itemInfo['before_suggest_qty'] != $qty) {
@@ -698,7 +698,7 @@ class Cart extends Object implements CartInterface
             if ($this->_checkoutSession->getUseNotice() === null) {
                 $this->_checkoutSession->setUseNotice(true);
             }
-            throw new \Magento\Framework\Exception\LocalizedException($result);
+            throw new \Magento\Framework\Exception\LocalizedException(__($result));
         }
 
         $this->_eventManager->dispatch(
diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php
old mode 100644
new mode 100755
index 9bf66e02a93d7b92d7f81ee1e67f6e4762c35886..f1a5b1c882dac2aee11c342f53ed2424c5ec0b9a
--- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php
@@ -79,6 +79,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultJson;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     protected function setUp()
     {
         $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -142,11 +147,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase
             ->method('create')
             ->willReturn($this->resultRaw);
 
-        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->setMethods(['setData'])
             ->getMock();
-        $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -166,6 +171,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute
+     *
+     * @return void
+     */
     public function testExecute()
     {
         $this->request->expects($this->once())
@@ -182,6 +192,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($this->resultRaw, $this->controller->execute());
     }
 
+    /**
+     * Test validate minimum amount
+     *
+     * @return void
+     */
     public function testValidateMinimumAmount()
     {
         $expectedResult = [
@@ -254,6 +269,11 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($this->resultJson, $this->controller->execute());
     }
 
+    /**
+     * Test validate minimum amount negative
+     *
+     * @return void
+     */
     public function testValidateMinimumAmountNegative()
     {
         $errorMessage = 'error_message';
diff --git a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php
index bc5499166cd061f17548ab4fe1d1c8833c5f34fa..e844d62b7d840199cd200112a946810c1db01e6d 100644
--- a/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php
+++ b/app/code/Magento/Checkout/Test/Unit/Helper/DataTest.php
@@ -123,8 +123,9 @@ class DataTest extends \PHPUnit_Framework_TestCase
             );
 
         $this->_checkoutSession = $arguments['checkoutSession'];
-        $localeDate = $arguments['localeDate'];
-        $localeDate->expects($this->any())->method('date')->will($this->returnValue('Oct 02, 2013'));
+        $arguments['localeDate']->expects($this->any())
+            ->method('formatDateTime')
+            ->willReturn('Oct 02, 2013');
 
         $this->_transportBuilder = $arguments['transportBuilder'];
 
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php
index 5306fdb26fd41f4b771b98b6f7b1013909dc0e15..0b1155258377a7144234d4bf6333bc842d489cd5 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Contents.php
@@ -14,7 +14,7 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
     protected $resultLayoutFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -22,13 +22,13 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
      * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
         \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         $this->resultLayoutFactory = $resultLayoutFactory;
         $this->resultJsonFactory = $resultJsonFactory;
@@ -62,7 +62,7 @@ class Contents extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
             return $resultLayout;
         } catch (\Exception $e) {
             $result = ['error' => true, 'message' => $e->getMessage()];
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             $resultJson->setData($result);
             return $resultJson;
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php
index c415e2331c36c68641046758bee3c390b6ac0db2..73389122633f1ccb2dca17a283aadc247aa87a8d 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php
@@ -11,7 +11,7 @@ use Magento\Framework\App\Filesystem\DirectoryList;
 class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -23,13 +23,13 @@ class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
         $this->resultRawFactory = $resultRawFactory;
@@ -67,7 +67,7 @@ class DeleteFiles extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
             return $this->resultRawFactory->create();
         } catch (\Exception $e) {
             $result = ['error' => true, 'message' => $e->getMessage()];
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData($result);
         }
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php
index a9fde1794b9da9fac7365961c40ba097e3750b89..2566d3159e47103ffc2dbcc22420a9bd904241fa 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFolder.php
@@ -9,7 +9,7 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
 class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
         $this->resultRawFactory = $resultRawFactory;
@@ -48,7 +48,7 @@ class DeleteFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
             return $this->resultRawFactory->create();
         } catch (\Exception $e) {
             $result = ['error' => true, 'message' => $e->getMessage()];
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             return $resultJson->setData($result);
         }
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php
index c270e3463f9189d5d0cd1f9eae97d001fb900ae3..24240b5ab25e7ce921706eb32a34b3688c1318da 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/NewFolder.php
@@ -9,19 +9,19 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
 class NewFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         $this->resultJsonFactory = $resultJsonFactory;
         parent::__construct($context, $coreRegistry);
@@ -42,7 +42,7 @@ class NewFolder extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
         } catch (\Exception $e) {
             $result = ['error' => true, 'message' => $e->getMessage()];
         }
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($result);
     }
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php
index 00950a5390e6b3d61f2c38f43131b99d40ff6b5a..9d70dd5a038de40c035962a5230ff3ad9d6789d6 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/TreeJson.php
@@ -9,7 +9,7 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
 class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -21,13 +21,13 @@ class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
         $this->layoutFactory = $layoutFactory;
@@ -42,7 +42,7 @@ class TreeJson extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
      */
     public function execute()
     {
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         try {
             $this->_initAction();
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php
index 61b1c8f631b49b27a981880e13e0e1fb6fd4370e..b05ff1ac92bd142d687d9647d0aa666be4e62fc4 100755
--- a/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/Upload.php
@@ -9,19 +9,19 @@ namespace Magento\Cms\Controller\Adminhtml\Wysiwyg\Images;
 class Upload extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
      * @param \Magento\Framework\Registry $coreRegistry
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
         \Magento\Framework\Registry $coreRegistry,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         $this->resultJsonFactory = $resultJsonFactory;
         parent::__construct($context, $coreRegistry);
@@ -41,7 +41,7 @@ class Upload extends \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images
         } catch (\Exception $e) {
             $result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
         }
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($result);
     }
diff --git a/app/code/Magento/Cms/Model/BlockRepository.php b/app/code/Magento/Cms/Model/BlockRepository.php
index 5b1607cc23cd59492dbced7a224ae9f2292d60fd..520add71eb28b864280d9cc2979859400fb04c6f 100644
--- a/app/code/Magento/Cms/Model/BlockRepository.php
+++ b/app/code/Magento/Cms/Model/BlockRepository.php
@@ -73,7 +73,7 @@ class BlockRepository
         try {
             $this->resource->save($block);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException($exception->getMessage());
+            throw new CouldNotSaveException(__($exception->getMessage()));
         }
         return $block;
     }
@@ -90,7 +90,7 @@ class BlockRepository
         $block = $this->blockFactory->create();
         $this->resource->load($block, $blockId);
         if (!$block->getId()) {
-            throw new NoSuchEntityException(sprintf('CMS Block with id "%s" does not exist.', $blockId));
+            throw new NoSuchEntityException(__('CMS Block with id "%1" does not exist.', $blockId));
         }
         return $block;
     }
@@ -123,7 +123,7 @@ class BlockRepository
         try {
             $this->resource->delete($block);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index 2faccd03d4a3e52b456f8255f07ae86bcde747e0..67815ec24adb01de14531640a2cdbeec49f2a471 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -72,7 +72,7 @@ class PageRepository
         try {
             $this->resource->save($page);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException($exception->getMessage());
+            throw new CouldNotSaveException(__($exception->getMessage()));
         }
         return $page;
     }
@@ -89,7 +89,7 @@ class PageRepository
         $page = $this->pageFactory->create();
         $this->resource->load($page, $pageId);
         if (!$page->getId()) {
-            throw new NoSuchEntityException(sprintf('CMS Page with id "%s" does not exist.', $pageId));
+            throw new NoSuchEntityException(__('CMS Page with id "%1" does not exist.', $pageId));
         }
         return $page;
     }
@@ -122,7 +122,7 @@ class PageRepository
         try {
             $this->resource->delete($page);
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException($exception->getMessage());
+            throw new CouldNotDeleteException(__($exception->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/Cms/Model/Resource/Page.php b/app/code/Magento/Cms/Model/Resource/Page.php
index 8d080ae79d40927e232f61d55d39bd8de8387de6..fea879a1ca63397557bfc749d2dafaf9fd8ee5e6 100644
--- a/app/code/Magento/Cms/Model/Resource/Page.php
+++ b/app/code/Magento/Cms/Model/Resource/Page.php
@@ -105,11 +105,15 @@ class Page extends \Magento\Framework\Model\Resource\Db\AbstractDb
         }
 
         if (!$this->isValidPageIdentifier($object)) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('The page URL key contains capital letters or disallowed symbols.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('The page URL key contains capital letters or disallowed symbols.')
+            );
         }
 
         if ($this->isNumericPageIdentifier($object)) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('The page URL key cannot be made of only numbers.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('The page URL key cannot be made of only numbers.')
+            );
         }
 
         if ($object->isObjectNew() && !$object->hasCreationTime()) {
diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php
new file mode 100755
index 0000000000000000000000000000000000000000..9fd408462cfc6a5918fa511605c160c3ad05c7fd
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/Edit/FormTest.php
@@ -0,0 +1,289 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Cms\Test\Unit\Block\Adminhtml\Block\Edit;
+
+/**
+ * @SuppressWarnings(PHPMD.TooManyFields)
+ */
+class FormTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $registry;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $systemStore;
+
+    /**
+     * @var array
+     */
+    protected $storeValues = [1, 2];
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $field;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $config;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $wysiwygConfig;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $store;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeManager;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $fieldSet;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $form;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $formFactory;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $eventManager;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $scopeConfig;
+
+    /**
+     * @var string
+     */
+    protected $action = 'test';
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $urlBuilder;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $appState;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $viewFileSystem;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $rootDirectory;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $logger;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $fileSystem;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $context;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $layout;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $model;
+
+    /**
+     * @var \Magento\Cms\Block\Adminhtml\Block\Edit\Form
+     */
+    protected $block;
+
+    /**
+     * Sets up the fixture, for example, open a network connection.
+     * This method is called before a test is executed.
+     *
+     * @return void
+     */
+    public function setUp()
+    {
+        $this->model = $this->getMock('Magento\Cms\Model\Block', ['getBlockId', 'setStoreId'], [], '', false);
+
+        $this->registry = $this->getMock('Magento\Framework\Registry', [], [], '', false);
+        $this->registry->expects($this->once())->method('registry')->with('cms_block')->willReturn($this->model);
+
+        $this->systemStore = $this->getMock('Magento\Store\Model\System\Store', [], [], '', false);
+        $this->systemStore->expects($this->any())
+            ->method('getStoreValuesForForm')
+            ->with(false, true)
+            ->willReturn($this->storeValues);
+
+        $this->field = $this->getMock('Magento\Framework\Data\Form\Element\AbstractElement', [], [], '', false);
+        $this->config = $this->getMock('Magento\Framework\Object', [], [], '', false);
+        $this->store = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
+        $this->storeManager = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
+        $this->fieldSet = $this->getMock('Magento\Framework\Data\Form\Element\Fieldset', [], [], '', false);
+        $this->eventManager = $this->getMock('Magento\Framework\Event\ManagerInterface', [], [], '', false);
+        $this->scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface', [], [], '', false);
+        $this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface', [], [], '', false);
+        $this->appState = $this->getMock('Magento\Framework\App\State', [], [], '', false);
+        $this->viewFileSystem = $this->getMock('Magento\Framework\View\FileSystem', [], [], '', false);
+        $this->logger = $this->getMock('Psr\Log\LoggerInterface', [], [], '', false);
+        $this->rootDirectory = $this->getMock(
+            'Magento\Framework\Filesystem\Directory\ReadInterface',
+            [],
+            [],
+            '',
+            false
+        );
+        $this->layout = $this->getMock('Magento\Framework\View\LayoutInterface', [], [], '', false);
+
+        $this->fileSystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
+        $this->fileSystem->expects($this->atLeastOnce())->method('getDirectoryRead')->willReturn($this->rootDirectory);
+
+        $this->wysiwygConfig = $this->getMock('Magento\Cms\Model\Wysiwyg\Config', [], [], '', false);
+        $this->wysiwygConfig->expects($this->once())->method('getConfig')->willReturn($this->config);
+
+        $this->form = $this->getMock('Magento\Framework\Data\Form', [], [], '', false);
+        $this->form->expects($this->once())->method('addFieldset')->with(
+            'base_fieldset',
+            ['legend' => __('General Information'), 'class' => 'fieldset-wide']
+        )->willReturn($this->fieldSet);
+
+        $this->formFactory = $this->getMock('\Magento\Framework\Data\FormFactory', [], [], '', false);
+        $this->formFactory->expects($this->once())
+            ->method('create')
+            ->with(['data' => ['id' => 'edit_form', 'action' => $this->action, 'method' => 'post']])
+            ->willReturn($this->form);
+
+        $this->context = $this->getMock('Magento\Backend\Block\Template\Context', [], [], '', false);
+        $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager);
+        $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig);
+        $this->context->expects($this->once())->method('getStoreManager')->willReturn($this->storeManager);
+        $this->context->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilder);
+        $this->context->expects($this->once())->method('getAppState')->willReturn($this->appState);
+        $this->context->expects($this->once())->method('getViewFileSystem')->willReturn($this->viewFileSystem);
+        $this->context->expects($this->once())->method('getFilesystem')->willReturn($this->fileSystem);
+        $this->context->expects($this->once())->method('getLogger')->willReturn($this->logger);
+        $this->context->expects($this->once())->method('getLayout')->willReturn($this->layout);
+
+        /** @var \Magento\Cms\Block\Adminhtml\Block\Edit\Form $block */
+        $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
+            ->getObject(
+                'Magento\Cms\Block\Adminhtml\Block\Edit\Form',
+                [
+                    'formFactory' => $this->formFactory,
+                    'registry' => $this->registry,
+                    'wysiwygConfig' => $this->wysiwygConfig,
+                    'context' => $this->context,
+                    'systemStore' => $this->systemStore
+                ]
+            );
+        $this->block->setData('action', $this->action);
+    }
+
+    /**
+     * Test prepare form model has no block id and single store mode is on
+     *
+     * @return void
+     */
+    public function testPrepareFormModelHasNoBlockIdAndSingleStoreMode()
+    {
+        $blockId = null;
+        $storeId = 1;
+
+        $this->model->expects($this->once())->method('getBlockId')->willReturn($blockId);
+        $this->model->expects($this->once())->method('setStoreId')->with($storeId);
+
+        $this->store->expects($this->atLeastOnce())->method('getId')->willReturn($storeId);
+
+        $this->storeManager->expects($this->once())->method('isSingleStoreMode')->willReturn(true);
+        $this->storeManager->expects($this->atLeastOnce())->method('getStore')->with(true)->willReturn($this->store);
+
+        $this->fieldSet->expects($this->at(2))
+            ->method('addField')
+            ->with(
+                'store_id',
+                'hidden',
+                ['name' => 'stores[]', 'value' => $storeId]
+            )
+            ->willReturn($this->field);
+
+        $this->block->toHtml();
+    }
+
+    /**
+     * Test prepare form model has block id and signle store mode is off
+     *
+     * @return void
+     */
+    public function testPrepareFormModelHasBlockIdAndNonSingleStoreMode()
+    {
+        $blockId = 'id';
+
+        $renderer = $this->getMock(
+            'Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element',
+            [],
+            [],
+            '',
+            false
+        );
+
+        $this->model->expects($this->once())->method('getBlockId')->willReturn($blockId);
+
+        $this->layout->expects($this->once())
+            ->method('createBlock')
+            ->with('Magento\Backend\Block\Store\Switcher\Form\Renderer\Fieldset\Element')
+            ->willReturn($renderer);
+
+        $this->field->expects($this->once())->method('setRenderer')->with($renderer);
+
+        $this->fieldSet->expects($this->at(0))->method('addField')->with('block_id', 'hidden', ['name' => 'block_id']);
+        $this->fieldSet->expects($this->at(3))
+            ->method('addField')
+            ->with(
+                'store_id',
+                'multiselect',
+                [
+                    'name' => 'stores[]',
+                    'label' => __('Store View'),
+                    'title' => __('Store View'),
+                    'required' => true,
+                    'values' => $this->storeValues
+                ]
+            )->willReturn($this->field);
+
+        $this->block->toHtml();
+    }
+}
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..3b4ecc8ee107011d0271ede942c226a198e065b2
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Index/IndexTest.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Cms\Test\Unit\Controller\Index;
+
+class IndexTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Cms\Controller\Index\Index
+     */
+    protected $controller;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $cmsHelperMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $requestMock;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\ForwardFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $forwardFactoryMock;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\Forward|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $forwardMock;
+
+    /**
+     * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resultPageMock;
+
+    /**
+     * @var string
+     */
+    protected $pageId = 'home';
+
+    protected function setUp()
+    {
+        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
+        $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
+        $this->resultPageMock = $this->getMockBuilder('\Magento\Framework\View\Result\Page')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardFactoryMock = $this->getMockBuilder('\Magento\Framework\Controller\Result\ForwardFactory')
+            ->setMethods(['create'])
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardFactoryMock->expects($this->any())
+            ->method('create')
+            ->willReturn($this->forwardMock);
+
+        $scopeConfigMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
+        $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
+        $this->cmsHelperMock = $this->getMock('Magento\Cms\Helper\Page', [], [], '', false);
+        $valueMap = [
+            [
+                'Magento\Framework\App\Config\ScopeConfigInterface',
+                $scopeConfigMock,
+            ],
+            ['Magento\Cms\Helper\Page', $this->cmsHelperMock],
+        ];
+        $objectManagerMock->expects($this->any())->method('get')->willReturnMap($valueMap);
+        $scopeConfigMock->expects($this->once())
+            ->method('getValue')
+            ->with(
+                \Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE,
+                \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+            )
+            ->willReturn($this->pageId);
+        $this->controller = $helper->getObject(
+            'Magento\Cms\Controller\Index\Index',
+            [
+                'response' => $responseMock,
+                'objectManager' => $objectManagerMock,
+                'request' => $this->requestMock,
+                'resultForwardFactory' => $this->forwardFactoryMock
+            ]
+        );
+    }
+
+    public function testExecuteResultPage()
+    {
+        $this->cmsHelperMock->expects($this->once())
+            ->method('prepareResultPage')
+            ->with($this->controller, $this->pageId)
+            ->willReturn($this->resultPageMock);
+        $this->assertSame($this->resultPageMock, $this->controller->execute());
+    }
+
+    public function testExecuteResultForward()
+    {
+        $this->forwardMock->expects($this->once())
+            ->method('forward')
+            ->with('defaultIndex')
+            ->willReturnSelf();
+        $this->assertSame($this->forwardMock, $this->controller->execute());
+    }
+}
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..df009be3bb0c7a71d9d0f7040d4215b40c7a7003
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Page/ViewTest.php
@@ -0,0 +1,111 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Cms\Test\Unit\Controller\Page;
+
+class ViewTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Cms\Controller\Page\View
+     */
+    protected $controller;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $cmsHelperMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $requestMock;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\ForwardFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $forwardFactoryMock;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\Forward|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $forwardMock;
+
+    /**
+     * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resultPageMock;
+
+    /**
+     * @var string
+     */
+    protected $pageId = '2';
+
+    protected function setUp()
+    {
+        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
+        $responseMock = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false);
+        $this->resultPageMock = $this->getMockBuilder('\Magento\Framework\View\Result\Page')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardFactoryMock = $this->getMockBuilder('\Magento\Framework\Controller\Result\ForwardFactory')
+            ->setMethods(['create'])
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Forward')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->forwardFactoryMock->expects($this->any())
+            ->method('create')
+            ->willReturn($this->forwardMock);
+
+        $this->requestMock = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
+        $this->cmsHelperMock = $this->getMock('Magento\Cms\Helper\Page', [], [], '', false);
+        $objectManagerMock->expects($this->once())->method('get')->willReturn($this->cmsHelperMock);
+        $this->controller = $helper->getObject(
+            'Magento\Cms\Controller\Page\View',
+            [
+                'response' => $responseMock,
+                'objectManager' => $objectManagerMock,
+                'request' => $this->requestMock,
+                'resultForwardFactory' => $this->forwardFactoryMock
+            ]
+        );
+    }
+
+    public function testExecuteResultPage()
+    {
+        $this->requestMock->expects($this->atLeastOnce())
+            ->method('getParam')
+            ->willReturnMap(
+                [
+                    ['page_id', $this->pageId, $this->pageId],
+                    ['id', false, $this->pageId]
+                ]
+            );
+        $this->cmsHelperMock->expects($this->once())
+            ->method('prepareResultPage')
+            ->with($this->controller, $this->pageId)
+            ->willReturn($this->resultPageMock);
+        $this->assertSame($this->resultPageMock, $this->controller->execute());
+    }
+
+    public function testExecuteResultForward()
+    {
+        $this->requestMock->expects($this->atLeastOnce())
+            ->method('getParam')
+            ->willReturnMap(
+                [
+                    ['page_id', $this->pageId, $this->pageId],
+                    ['id', false, $this->pageId]
+                ]
+            );
+        $this->forwardMock->expects($this->once())
+            ->method('forward')
+            ->with('noroute')
+            ->willReturnSelf();
+        $this->assertSame($this->forwardMock, $this->controller->execute());
+    }
+}
diff --git a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php
index a5249fc44892f7406362377ef3d2b3b03dadbe03..3c51993ca6e1e886558342fd81850ff5102823eb 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Baseurl.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Baseurl.php
@@ -51,7 +51,7 @@ class Baseurl extends \Magento\Framework\App\Config\Value
             $field = $this->getFieldConfig();
             $label = $field && is_array($field) ? $field['label'] : 'value';
             $msg = __('Invalid %1. %2', $label, $e->getMessage());
-            $error = new \Magento\Framework\Exception\LocalizedException($msg, [], $e);
+            $error = new \Magento\Framework\Exception\LocalizedException($msg, $e);
             throw $error;
         }
     }
@@ -164,7 +164,7 @@ class Baseurl extends \Magento\Framework\App\Config\Value
             $this->_assertStartsWithValuesOrUrl($values, $value);
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             $msg = __('%1 An empty value is allowed as well.', $e->getMessage());
-            $error = new \Magento\Framework\Exception\LocalizedException($msg, [], $e);
+            $error = new \Magento\Framework\Exception\LocalizedException($msg, $e);
             throw $error;
         }
     }
diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php
index d798402b72fdb599708cc0b4dd837be37044fa9a..5103829ca9c727eca0c514a364604491ae1b3e24 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Allow.php
@@ -68,7 +68,7 @@ class Allow extends AbstractCurrency
         }
 
         if ($exceptions) {
-            throw new \Magento\Framework\Exception\LocalizedException(join("\n", $exceptions));
+            throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions)));
         }
 
         return $this;
diff --git a/app/code/Magento/Config/Model/Config/Backend/File.php b/app/code/Magento/Config/Model/Config/Backend/File.php
index ad8d2de49e2f1d84d1b869a40f6dcef449898c7c..e7a119f79af9f0bf78d8f459ff0d30875abd097b 100644
--- a/app/code/Magento/Config/Model/Config/Backend/File.php
+++ b/app/code/Magento/Config/Model/Config/Backend/File.php
@@ -98,7 +98,7 @@ class File extends \Magento\Framework\App\Config\Value
                 $uploader->addValidateCallback('size', $this, 'validateMaxSize');
                 $result = $uploader->save($uploadDir);
             } catch (\Exception $e) {
-                throw new \Magento\Framework\Exception\LocalizedException($e->getMessage());
+                throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
             }
 
             $filename = $result['file'];
diff --git a/app/code/Magento/Config/Model/Config/Backend/Locale.php b/app/code/Magento/Config/Model/Config/Backend/Locale.php
index 5f4b102a4b0a63685cb72547ef9ab1e1bfd6f71f..0881afdebfc3839d52d0c27de0052ae6a8bd68b1 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Locale.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Locale.php
@@ -115,7 +115,7 @@ class Locale extends \Magento\Framework\App\Config\Value
             }
         }
         if ($exceptions) {
-            throw new \Magento\Framework\Exception\LocalizedException(join("\n", $exceptions));
+            throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $exceptions)));
         }
 
         return $this;
diff --git a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
index 1980a0228614bfaf192001f4cc560d1846af6a87..51f425d487f302c4062622c25db1e4fa8ef0f1bc 100644
--- a/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
+++ b/app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
@@ -99,7 +99,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
 
         $childrenIds = array_values($this->configurableType->getChildrenIds($product->getId())[0]);
         if (in_array($child->getId(), $childrenIds)) {
-            throw new StateException('Product has been already attached');
+            throw new StateException(__('Product has been already attached'));
         }
 
         $childrenIds[] = $child->getId();
@@ -117,7 +117,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
 
         if ($product->getTypeId() != \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE) {
             throw new InputException(
-                sprintf('Product with specified sku: %s is not a configurable product', $sku)
+                __('Product with specified sku: %1 is not a configurable product', $sku)
             );
         }
 
@@ -130,7 +130,7 @@ class LinkManagement implements \Magento\ConfigurableProduct\Api\LinkManagementI
             $ids[] = $option->getId();
         }
         if (count($options) == count($ids)) {
-            throw new NoSuchEntityException('Requested option doesn\'t exist');
+            throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
         }
         $product->addData(['associated_product_ids' => $ids]);
         $product->save();
diff --git a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
index 0106b5292d5c70827b0811e95d367b873cb2ad58..da8e040874852d2af958a2d52345192c7cbc75b1 100644
--- a/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
+++ b/app/code/Magento/ConfigurableProduct/Model/OptionRepository.php
@@ -92,7 +92,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
         /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $configurableAttribute */
         $configurableAttribute = $collection->getFirstItem();
         if (!$configurableAttribute->getId()) {
-            throw new NoSuchEntityException(sprintf('Requested option doesn\'t exist: %s', $id));
+            throw new NoSuchEntityException(__('Requested option doesn\'t exist: %1', $id));
         }
         $prices = $configurableAttribute->getPrices();
         if (is_array($prices)) {
@@ -144,7 +144,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
             $this->optionResource->delete($option);
         } catch (\Exception $exception) {
             throw new StateException(
-                sprintf('Cannot delete option with id: %s', $option->getId())
+                __('Cannot delete option with id: %1', $option->getId())
             );
         }
         return true;
@@ -160,7 +160,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
         /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $option */
         $option = $attributeCollection->getItemById($id);
         if ($option === null) {
-            throw new NoSuchEntityException('Requested option doesn\'t exist');
+            throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
         }
         return $this->delete($option);
     }
@@ -179,8 +179,10 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
             $configurableAttribute->load($option->getId());
             if (!$configurableAttribute->getId() || $configurableAttribute->getProductId() != $product->getId()) {
                 throw new NoSuchEntityException(
-                    'Option with id "%option_id" not found',
-                    ['option_id' => $option->getId()]
+                    __(
+                        'Option with id "%1" not found',
+                        $option->getId()
+                    )
                 );
             }
             $configurableAttribute->addData($option->getData());
@@ -192,8 +194,10 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
                 $configurableAttribute->save();
             } catch (\Exception $e) {
                 throw new CouldNotSaveException(
-                    'Could not update option with id "%option_id"',
-                    ['option_id' => $option->getId()]
+                    __(
+                        'Could not update option with id "%1"',
+                        $option->getId()
+                    )
                 );
             }
         } else {
@@ -208,7 +212,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
             $eavAttribute = $this->productAttributeRepository->get($option->getAttributeId());
             $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute);
             if ($configurableAttribute->getId()) {
-                throw new CouldNotSaveException('Product already has this option');
+                throw new CouldNotSaveException(__('Product already has this option'));
             }
 
             $configurableAttributesData = [
@@ -225,14 +229,14 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
                 $product->setStoreId($this->storeManager->getStore(Store::ADMIN_CODE)->getId());
                 $product->save();
             } catch (\Exception $e) {
-                throw new CouldNotSaveException('An error occurred while saving option');
+                throw new CouldNotSaveException(__('An error occurred while saving option'));
             }
 
             $configurableAttribute = $this->configurableAttributeFactory->create();
             $configurableAttribute->loadByProductAndAttribute($product, $eavAttribute);
         }
         if (!$configurableAttribute->getId()) {
-            throw new CouldNotSaveException('An error occurred while saving option');
+            throw new CouldNotSaveException(__('An error occurred while saving option'));
         }
         return $configurableAttribute->getId();
     }
@@ -249,7 +253,7 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
         $product = $this->productRepository->get($sku);
         if (\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE !== $product->getTypeId()) {
             throw new InputException(
-                sprintf('Only implemented for configurable product: %s', $sku)
+                __('Only implemented for configurable product: %1', $sku)
             );
         }
         return $product;
@@ -278,26 +282,26 @@ class OptionRepository implements \Magento\ConfigurableProduct\Api\OptionReposit
     {
         $inputException = new InputException();
         if (!$option->getAttributeId()) {
-            $inputException->addError('Option attribute ID is not specified.');
+            $inputException->addError(__('Option attribute ID is not specified.'));
         }
         if (!$option->getType()) {
-            $inputException->addError('Option type is not specified.');
+            $inputException->addError(__('Option type is not specified.'));
         }
         if (!$option->getLabel()) {
-            $inputException->addError('Option label is not specified.');
+            $inputException->addError(__('Option label is not specified.'));
         }
         if (!$option->getValues()) {
-            $inputException->addError('Option values are not specified.');
+            $inputException->addError(__('Option values are not specified.'));
         } else {
             foreach ($option->getValues() as $optionValue) {
                 if (!$optionValue->getValueIndex()) {
-                    $inputException->addError('Value index is not specified for an option.');
+                    $inputException->addError(__('Value index is not specified for an option.'));
                 }
                 if (null === $optionValue->getPricingValue()) {
-                    $inputException->addError('Price is not specified for an option.');
+                    $inputException->addError(__('Price is not specified for an option.'));
                 }
                 if (null === $optionValue->getIsPercent()) {
-                    $inputException->addError('Percent/absolute is not specified for an option.');
+                    $inputException->addError(__('Percent/absolute is not specified for an option.'));
                 }
             }
         }
diff --git a/app/code/Magento/Customer/Controller/Account/CreatePost.php b/app/code/Magento/Customer/Controller/Account/CreatePost.php
index 55d7bf4c4a11535abe6f9220af2a3f69e68b3b6e..fcefbfaa9fcd69123926b3b4160742ffc68f58fb 100644
--- a/app/code/Magento/Customer/Controller/Account/CreatePost.php
+++ b/app/code/Magento/Customer/Controller/Account/CreatePost.php
@@ -1,13 +1,14 @@
 <?php
 /**
- *
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
 namespace Magento\Customer\Controller\Account;
 
+use Magento\Customer\Model\Account\Redirect as AccountRedirect;
 use Magento\Customer\Api\Data\AddressInterface;
 use Magento\Customer\Model\Url;
+use Magento\Framework\Api\DataObjectHelper;
 use Magento\Framework\App\Action\Context;
 use Magento\Customer\Model\Session;
 use Magento\Framework\Controller\Result\RedirectFactory;
@@ -28,19 +29,12 @@ use Magento\Framework\Escaper;
 use Magento\Customer\Model\CustomerExtractor;
 use Magento\Framework\Exception\StateException;
 use Magento\Framework\Exception\InputException;
-use Magento\Store\Model\ScopeInterface;
 
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class CreatePost extends \Magento\Customer\Controller\Account
 {
-    /** @var ScopeConfigInterface */
-    protected $scopeConfig;
-
-    /** @var StoreManagerInterface */
-    protected $storeManager;
-
     /** @var AccountManagementInterface */
     protected $accountManagement;
 
@@ -77,10 +71,13 @@ class CreatePost extends \Magento\Customer\Controller\Account
     /** @var \Magento\Framework\UrlInterface */
     protected $urlModel;
 
+    /** @var DataObjectHelper  */
+    protected $dataObjectHelper;
+
     /**
-     * @var \Magento\Framework\Api\DataObjectHelper
+     * @var AccountRedirect
      */
-    protected $dataObjectHelper;
+    private $accountRedirect;
 
     /**
      * @param Context $context
@@ -101,7 +98,8 @@ class CreatePost extends \Magento\Customer\Controller\Account
      * @param Registration $registration
      * @param Escaper $escaper
      * @param CustomerExtractor $customerExtractor
-     * @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
+     * @param DataObjectHelper $dataObjectHelper
+     * @param AccountRedirect $accountRedirect
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -124,7 +122,8 @@ class CreatePost extends \Magento\Customer\Controller\Account
         Registration $registration,
         Escaper $escaper,
         CustomerExtractor $customerExtractor,
-        \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
+        DataObjectHelper $dataObjectHelper,
+        AccountRedirect $accountRedirect
     ) {
         $this->scopeConfig = $scopeConfig;
         $this->storeManager = $storeManager;
@@ -141,7 +140,13 @@ class CreatePost extends \Magento\Customer\Controller\Account
         $this->customerExtractor = $customerExtractor;
         $this->urlModel = $urlFactory->create();
         $this->dataObjectHelper = $dataObjectHelper;
-        parent::__construct($context, $customerSession, $resultRedirectFactory, $resultPageFactory);
+        $this->accountRedirect = $accountRedirect;
+        parent::__construct(
+            $context,
+            $customerSession,
+            $resultRedirectFactory,
+            $resultPageFactory
+        );
     }
 
     /**
@@ -257,9 +262,8 @@ class CreatePost extends \Magento\Customer\Controller\Account
                 $resultRedirect->setUrl($this->_redirect->success($url));
             } else {
                 $this->_getSession()->setCustomerDataAsLoggedIn($customer);
-
                 $this->messageManager->addSuccess($this->getSuccessMessage());
-                $resultRedirect->setUrl($this->getSuccessRedirect());
+                $resultRedirect = $this->accountRedirect->getRedirect();
             }
             return $resultRedirect;
         } catch (StateException $e) {
@@ -297,7 +301,7 @@ class CreatePost extends \Magento\Customer\Controller\Account
     protected function checkPasswordConfirmation($password, $confirmation)
     {
         if ($password != $confirmation) {
-            throw new InputException('Please make sure your passwords match.');
+            throw new InputException(__('Please make sure your passwords match.'));
         }
     }
 
@@ -329,23 +333,4 @@ class CreatePost extends \Magento\Customer\Controller\Account
         }
         return $message;
     }
-
-    /**
-     * Retrieve success redirect URL
-     *
-     * @return string
-     */
-    protected function getSuccessRedirect()
-    {
-        $redirectToDashboard = $this->scopeConfig->isSetFlag(
-            Url::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
-            ScopeInterface::SCOPE_STORE
-        );
-        if (!$redirectToDashboard && $this->_getSession()->getBeforeAuthUrl()) {
-            $successUrl = $this->_getSession()->getBeforeAuthUrl(true);
-        } else {
-            $successUrl = $this->urlModel->getUrl('*/*/index', ['_secure' => true]);
-        }
-        return $this->_redirect->success($successUrl);
-    }
 }
diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php
index bf13ee5fcc4ef2c3cc611ef2ec2d4d5aa860e896..a3df334fbf83560dc676ee96e415ff842a88ac30 100644
--- a/app/code/Magento/Customer/Controller/Account/EditPost.php
+++ b/app/code/Magento/Customer/Controller/Account/EditPost.php
@@ -81,6 +81,9 @@ class EditPost extends \Magento\Customer\Controller\Account
             $customerId = $this->_getSession()->getCustomerId();
             $customer = $this->customerExtractor->extract('customer_account_edit', $this->_request);
             $customer->setId($customerId);
+            if ($customer->getAddresses() == null) {
+                $customer->setAddresses($this->customerRepository->getById($customerId)->getAddresses());
+            }
 
             if ($this->getRequest()->getParam('change_password')) {
                 $currPass = $this->getRequest()->getPost('current_password');
diff --git a/app/code/Magento/Customer/Controller/Account/LoginPost.php b/app/code/Magento/Customer/Controller/Account/LoginPost.php
index acc5eb614bba76d01c15f09c63269b2bd55bc8ea..1f05dff29314ebeca53856b305565dca6619aeb1 100644
--- a/app/code/Magento/Customer/Controller/Account/LoginPost.php
+++ b/app/code/Magento/Customer/Controller/Account/LoginPost.php
@@ -1,19 +1,16 @@
 <?php
 /**
- *
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
 namespace Magento\Customer\Controller\Account;
 
+use Magento\Customer\Model\Account\Redirect as AccountRedirect;
 use Magento\Framework\App\Action\Context;
 use Magento\Customer\Model\Session;
 use Magento\Framework\Controller\Result\RedirectFactory;
 use Magento\Framework\View\Result\PageFactory;
-use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Store\Model\StoreManagerInterface;
 use Magento\Customer\Api\AccountManagementInterface;
-use Magento\Framework\Url\DecoderInterface;
 use Magento\Customer\Model\Url as CustomerUrl;
 use Magento\Framework\Exception\EmailNotConfirmedException;
 use Magento\Framework\Exception\AuthenticationException;
@@ -24,35 +21,26 @@ use Magento\Framework\Data\Form\FormKey\Validator;
  */
 class LoginPost extends \Magento\Customer\Controller\Account
 {
-    /** @var ScopeConfigInterface */
-    protected $scopeConfig;
-
-    /** @var StoreManagerInterface */
-    protected $storeManager;
-
     /** @var AccountManagementInterface */
     protected $customerAccountManagement;
 
-    /** @var DecoderInterface */
-    protected $urlDecoder;
-
-    /** @var CustomerUrl */
-    protected $customerUrl;
-
     /** @var Validator */
     protected $formKeyValidator;
 
+    /**
+     * @var AccountRedirect
+     */
+    private $accountRedirect;
+
     /**
      * @param Context $context
      * @param Session $customerSession
      * @param RedirectFactory $resultRedirectFactory
      * @param PageFactory $resultPageFactory
-     * @param ScopeConfigInterface $scopeConfig
-     * @param StoreManagerInterface $storeManager
      * @param AccountManagementInterface $customerAccountManagement
-     * @param DecoderInterface $urlDecoder
      * @param CustomerUrl $customerHelperData
-     * @param \Magento\Framework\Data\Form\FormKey\Validator $formKeyValidator
+     * @param Validator $formKeyValidator
+     * @param AccountRedirect $accountRedirect
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -61,76 +49,21 @@ class LoginPost extends \Magento\Customer\Controller\Account
         Session $customerSession,
         RedirectFactory $resultRedirectFactory,
         PageFactory $resultPageFactory,
-        ScopeConfigInterface $scopeConfig,
-        StoreManagerInterface $storeManager,
         AccountManagementInterface $customerAccountManagement,
-        DecoderInterface $urlDecoder,
         CustomerUrl $customerHelperData,
-        Validator $formKeyValidator
+        Validator $formKeyValidator,
+        AccountRedirect $accountRedirect
     ) {
-        $this->scopeConfig = $scopeConfig;
-        $this->storeManager = $storeManager;
         $this->customerAccountManagement = $customerAccountManagement;
-        $this->urlDecoder = $urlDecoder;
         $this->customerUrl = $customerHelperData;
         $this->formKeyValidator = $formKeyValidator;
-        parent::__construct($context, $customerSession, $resultRedirectFactory, $resultPageFactory);
-    }
-
-    /**
-     * Define target URL and redirect customer after logging in
-     *
-     * @return \Magento\Framework\Controller\Result\Redirect
-     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
-     */
-    protected function loginPostRedirect()
-    {
-        $lastCustomerId = $this->_getSession()->getLastCustomerId();
-        if (isset(
-            $lastCustomerId
-            ) && $this->_getSession()->isLoggedIn() && $lastCustomerId != $this->_getSession()->getId()
-        ) {
-            $this->_getSession()->unsBeforeAuthUrl()->setLastCustomerId($this->_getSession()->getId());
-        }
-        if (!$this->_getSession()->getBeforeAuthUrl() ||
-            $this->_getSession()->getBeforeAuthUrl() == $this->storeManager->getStore()->getBaseUrl()
-        ) {
-            // Set default URL to redirect customer to
-            $this->_getSession()->setBeforeAuthUrl($this->customerUrl->getAccountUrl());
-            // Redirect customer to the last page visited after logging in
-            if ($this->_getSession()->isLoggedIn()) {
-                if (!$this->scopeConfig->isSetFlag(
-                    CustomerUrl::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
-                    \Magento\Store\Model\ScopeInterface::SCOPE_STORE
-                )
-                ) {
-                    $referer = $this->getRequest()->getParam(CustomerUrl::REFERER_QUERY_PARAM_NAME);
-                    if ($referer) {
-                        $referer = $this->urlDecoder->decode($referer);
-                        if ($this->_url->isOwnOriginUrl()) {
-                            $this->_getSession()->setBeforeAuthUrl($referer);
-                        }
-                    }
-                } elseif ($this->_getSession()->getAfterAuthUrl()) {
-                    $this->_getSession()->setBeforeAuthUrl($this->_getSession()->getAfterAuthUrl(true));
-                }
-            } else {
-                $this->_getSession()->setBeforeAuthUrl($this->customerUrl->getLoginUrl());
-            }
-        } elseif ($this->_getSession()->getBeforeAuthUrl() == $this->customerUrl->getLogoutUrl()) {
-            $this->_getSession()->setBeforeAuthUrl($this->customerUrl->getDashboardUrl());
-        } else {
-            if (!$this->_getSession()->getAfterAuthUrl()) {
-                $this->_getSession()->setAfterAuthUrl($this->_getSession()->getBeforeAuthUrl());
-            }
-            if ($this->_getSession()->isLoggedIn()) {
-                $this->_getSession()->setBeforeAuthUrl($this->_getSession()->getAfterAuthUrl(true));
-            }
-        }
-        /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
-        $resultRedirect = $this->resultRedirectFactory->create();
-        $resultRedirect->setUrl($this->_getSession()->getBeforeAuthUrl(true));
-        return $resultRedirect;
+        $this->accountRedirect = $accountRedirect;
+        parent::__construct(
+            $context,
+            $customerSession,
+            $resultRedirectFactory,
+            $resultPageFactory
+        );
     }
 
     /**
@@ -177,6 +110,6 @@ class LoginPost extends \Magento\Customer\Controller\Account
             }
         }
 
-        return $this->loginPostRedirect();
+        return $this->accountRedirect->getRedirect();
     }
 }
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index.php b/app/code/Magento/Customer/Controller/Adminhtml/Index.php
index 3ff36759a343142790e6636cd6dd23d4d501668e..eec31225f83eaf86c8d9ea536e45fd82c558e60f 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index.php
@@ -144,7 +144,7 @@ class Index extends \Magento\Backend\App\Action
     protected $resultForwardFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -174,7 +174,7 @@ class Index extends \Magento\Backend\App\Action
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
      * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      *
      * @SuppressWarnings(PHPMD.ExcessiveParameterList)
      */
@@ -204,7 +204,7 @@ class Index extends \Magento\Backend\App\Action
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
         \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         $this->_coreRegistry = $coreRegistry;
         $this->_fileFactory = $fileFactory;
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php
index 48b8430d70877c115627c07c2f3b277f5c0782f8..bd74b364b82266759ee55ee967a9327293e5a396 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/ResetPassword.php
@@ -34,7 +34,7 @@ class ResetPassword extends \Magento\Customer\Controller\Adminhtml\Index
         } catch (NoSuchEntityException $exception) {
             $resultRedirect->setPath('customer/index');
             return $resultRedirect;
-        } catch (\Magento\Framework\Validator\ValidatorException $exception) {
+        } catch (\Magento\Framework\Validator\Exception $exception) {
             $messages = $exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR);
             if (!count($messages)) {
                 $messages = $exception->getMessage();
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
index 3c2b02d7a7f06dd356600bb33420202d3792fec6..afe64d9c98455be2d298dd702485ef7851725e1f 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
@@ -252,7 +252,7 @@ class Save extends \Magento\Customer\Controller\Adminhtml\Index
                 $this->_coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, $customerId);
                 $this->messageManager->addSuccess(__('You saved the customer.'));
                 $returnToEdit = (bool)$this->getRequest()->getParam('back', false);
-            } catch (\Magento\Framework\Validator\ValidatorException $exception) {
+            } catch (\Magento\Framework\Validator\Exception $exception) {
                 $messages = $exception->getMessages();
                 if (empty($messages)) {
                     $messages = $exception->getMessage();
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php
index 3f925ba579e8f9c72a271b03677ee49d7fd2626f..3986551d78389058e3f503511c7bf9d621ee66f5 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Validate.php
@@ -49,7 +49,7 @@ class Validate extends \Magento\Customer\Controller\Adminhtml\Index
                 '\Magento\Customer\Api\Data\CustomerInterface'
             );
             $errors = $this->customerAccountManagement->validate($customer);
-        } catch (\Magento\Framework\Validator\ValidatorException $exception) {
+        } catch (\Magento\Framework\Validator\Exception $exception) {
             /* @var $error Error */
             foreach ($exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR) as $error) {
                 $errors[] = $error->getText();
@@ -102,7 +102,7 @@ class Validate extends \Magento\Customer\Controller\Adminhtml\Index
     /**
      * AJAX customer validation action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php
index c06a9540a4edf5c7932260ea45db498fda0e71da..86f937f8981a7fc110e63a31aee8e6ae0f40f1c6 100755
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/Viewfile.php
@@ -56,7 +56,7 @@ class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
      * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      * @param \Magento\Framework\Url\DecoderInterface $urlDecoder
      *
@@ -88,7 +88,7 @@ class Viewfile extends \Magento\Customer\Controller\Adminhtml\Index
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
         \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
         \Magento\Framework\Url\DecoderInterface $urlDecoder
     ) {
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php
index c267c46b590efc38cd6bab77a56920d36c70a766..af85244627703f4619e76ff433957d0e782a6d5d 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/System/Config/Validatevat/ValidateAdvanced.php
@@ -9,17 +9,17 @@ namespace Magento\Customer\Controller\Adminhtml\System\Config\Validatevat;
 class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Config\Validatevat
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -28,7 +28,7 @@ class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Con
     /**
      * Retrieve validation result as JSON
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -49,7 +49,7 @@ class ValidateAdvanced extends \Magento\Customer\Controller\Adminhtml\System\Con
                 $storeId
             );
 
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData(['valid' => $valid, 'group' => $groupId, 'success' => $success]);
     }
diff --git a/app/code/Magento/Customer/Controller/Ajax/Login.php b/app/code/Magento/Customer/Controller/Ajax/Login.php
index b705069c7c9b309de11eb665d394dbe8a2a54021..ad1e2cdd0cf74eadb20db3dde864b2545b2784e1 100644
--- a/app/code/Magento/Customer/Controller/Ajax/Login.php
+++ b/app/code/Magento/Customer/Controller/Ajax/Login.php
@@ -34,7 +34,7 @@ class Login extends \Magento\Framework\App\Action\Action
     protected $helper;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -50,7 +50,7 @@ class Login extends \Magento\Framework\App\Action\Action
      * @param \Magento\Customer\Model\Session $customerSession
      * @param \Magento\Framework\Json\Helper\Data $helper
      * @param AccountManagementInterface $customerAccountManagement
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
     public function __construct(
@@ -58,7 +58,7 @@ class Login extends \Magento\Framework\App\Action\Action
         \Magento\Customer\Model\Session $customerSession,
         \Magento\Framework\Json\Helper\Data $helper,
         AccountManagementInterface $customerAccountManagement,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
         parent::__construct($context);
@@ -112,7 +112,7 @@ class Login extends \Magento\Framework\App\Action\Action
         } else {
             $responseText = __('Login successful.');
         }
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData(['message' => $responseText]);
     }
diff --git a/app/code/Magento/Customer/Controller/Ajax/Logout.php b/app/code/Magento/Customer/Controller/Ajax/Logout.php
index 999f3d45fa7bf3b2bcb0328d2a2d2ea26183f959..69ce4693b035ebc3644eb74a74b28afc1725b146 100644
--- a/app/code/Magento/Customer/Controller/Ajax/Logout.php
+++ b/app/code/Magento/Customer/Controller/Ajax/Logout.php
@@ -21,7 +21,7 @@ class Logout extends \Magento\Framework\App\Action\Action
     protected $session;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -30,12 +30,12 @@ class Logout extends \Magento\Framework\App\Action\Action
      *
      * @param \Magento\Framework\App\Action\Context $context
      * @param \Magento\Customer\Model\Session $customerSession
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Framework\App\Action\Context $context,
         \Magento\Customer\Model\Session $customerSession,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->customerSession = $customerSession;
@@ -45,7 +45,7 @@ class Logout extends \Magento\Framework\App\Action\Action
     /**
      * Customer logout action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -54,7 +54,7 @@ class Logout extends \Magento\Framework\App\Action\Action
             ->setBeforeAuthUrl($this->_redirect->getRefererUrl())
             ->setLastCustomerId($lastCustomerId);
 
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData(['message' => 'Logout Successful']);
     }
diff --git a/app/code/Magento/Customer/Model/Account/Redirect.php b/app/code/Magento/Customer/Model/Account/Redirect.php
new file mode 100644
index 0000000000000000000000000000000000000000..e230390fa2a991eaa6e3ff1da7e8a14c34c6fb07
--- /dev/null
+++ b/app/code/Magento/Customer/Model/Account/Redirect.php
@@ -0,0 +1,199 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Customer\Model\Account;
+
+use Magento\Customer\Model\Session;
+use Magento\Customer\Model\Url as CustomerUrl;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\UrlInterface;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\Controller\Result\Redirect as ResultRedirect;
+use Magento\Framework\Controller\Result\RedirectFactory;
+use Magento\Framework\Url\DecoderInterface;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class Redirect
+{
+    /**
+     * @var RequestInterface
+     */
+    protected $request;
+
+    /**
+     * @var ScopeConfigInterface
+     */
+    protected $scopeConfig;
+
+    /**
+     * @var StoreManagerInterface
+     */
+    protected $storeManager;
+
+    /**
+     * @var DecoderInterface
+     */
+    protected $urlDecoder;
+
+    /**
+     * @var CustomerUrl
+     */
+    protected $customerUrl;
+
+    /**
+     * @var UrlInterface
+     */
+    protected $url;
+
+    /**
+     * @var RedirectFactory
+     */
+    protected $resultRedirectFactory;
+
+    /**
+     * @param RequestInterface $request
+     * @param Session $customerSession
+     * @param ScopeConfigInterface $scopeConfig
+     * @param StoreManagerInterface $storeManager
+     * @param UrlInterface $url
+     * @param DecoderInterface $urlDecoder
+     * @param CustomerUrl $customerUrl
+     * @param RedirectFactory $resultRedirectFactory
+     */
+    public function __construct(
+        RequestInterface $request,
+        Session $customerSession,
+        ScopeConfigInterface $scopeConfig,
+        StoreManagerInterface $storeManager,
+        UrlInterface $url,
+        DecoderInterface $urlDecoder,
+        CustomerUrl $customerUrl,
+        RedirectFactory $resultRedirectFactory
+    ) {
+        $this->request = $request;
+        $this->session = $customerSession;
+        $this->scopeConfig = $scopeConfig;
+        $this->storeManager = $storeManager;
+        $this->url = $url;
+        $this->urlDecoder = $urlDecoder;
+        $this->customerUrl = $customerUrl;
+        $this->resultRedirectFactory = $resultRedirectFactory;
+    }
+
+    /**
+     * Retrieve redirect
+     *
+     * @return ResultRedirect
+     */
+    public function getRedirect()
+    {
+        $this->updateLastCustomerId();
+        $this->prepareRedirectUrl();
+
+        /** @var ResultRedirect $resultRedirect */
+        $resultRedirect = $this->resultRedirectFactory->create();
+        $resultRedirect->setUrl($this->session->getBeforeAuthUrl(true));
+        return $resultRedirect;
+    }
+
+    /**
+     * Update last customer id, if required
+     *
+     * @return void
+     */
+    protected function updateLastCustomerId()
+    {
+        $lastCustomerId = $this->session->getLastCustomerId();
+        if (isset($lastCustomerId)
+            && $this->session->isLoggedIn()
+            && $lastCustomerId != $this->session->getId()
+        ) {
+            $this->session->unsBeforeAuthUrl()
+                ->setLastCustomerId($this->session->getId());
+        }
+    }
+
+    /**
+     * Prepare redirect URL
+     *
+     * @return void
+     */
+    protected function prepareRedirectUrl()
+    {
+        $baseUrl = $this->storeManager->getStore()->getBaseUrl();
+
+        $url = $this->session->getBeforeAuthUrl();
+        if (!$url) {
+            $url = $baseUrl;
+        }
+
+        switch ($url) {
+            case $baseUrl:
+                if ($this->session->isLoggedIn()) {
+                    $this->processLoggedCustomer();
+                } else {
+                    $this->applyRedirect($this->customerUrl->getLoginUrl());
+                }
+                break;
+
+            case $this->customerUrl->getLogoutUrl():
+                $this->applyRedirect($this->customerUrl->getDashboardUrl());
+                break;
+
+            default:
+                if (!$this->session->getAfterAuthUrl()) {
+                    $this->session->setAfterAuthUrl($this->session->getBeforeAuthUrl());
+                }
+                if ($this->session->isLoggedIn()) {
+                    $this->applyRedirect($this->session->getAfterAuthUrl(true));
+                }
+                break;
+        }
+    }
+
+    /**
+     * Prepare redirect URL for logged in customer
+     *
+     * Redirect customer to the last page visited after logging in.
+     *
+     * @return void
+     */
+    protected function processLoggedCustomer()
+    {
+        // Set default redirect URL for logged in customer
+        $this->applyRedirect($this->customerUrl->getAccountUrl());
+
+        if (!$this->scopeConfig->isSetFlag(
+            CustomerUrl::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD,
+            ScopeInterface::SCOPE_STORE
+        )
+        ) {
+            $referer = $this->request->getParam(CustomerUrl::REFERER_QUERY_PARAM_NAME);
+            if ($referer) {
+                $referer = $this->urlDecoder->decode($referer);
+                if ($this->url->isOwnOriginUrl()) {
+                    $this->applyRedirect($referer);
+                }
+            }
+        } elseif ($this->session->getAfterAuthUrl()) {
+            $this->applyRedirect($this->session->getAfterAuthUrl(true));
+        }
+    }
+
+    /**
+     * Prepare redirect URL
+     *
+     * @param string $url
+     * @return void
+     */
+    private function applyRedirect($url)
+    {
+        $this->session->setBeforeAuthUrl($url);
+    }
+}
diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php
index 1b9c851c5c3ef0bbb8610ebfb5265bef1b1eeb60..129f46990118ab34ef0bd442198d93f5a5d325c3 100644
--- a/app/code/Magento/Customer/Model/AccountManagement.php
+++ b/app/code/Magento/Customer/Model/AccountManagement.php
@@ -291,7 +291,7 @@ class AccountManagement implements AccountManagementInterface
     {
         $customer = $this->customerRepository->get($email, $websiteId);
         if (!$customer->getConfirmation()) {
-            throw new InvalidTransitionException('No confirmation needed.');
+            throw new InvalidTransitionException(__('No confirmation needed.'));
         }
 
         try {
@@ -336,11 +336,11 @@ class AccountManagement implements AccountManagementInterface
     {
         // check if customer is inactive
         if (!$customer->getConfirmation()) {
-            throw new InvalidTransitionException('Account already active');
+            throw new InvalidTransitionException(__('Account already active'));
         }
 
         if ($customer->getConfirmation() !== $confirmationKey) {
-            throw new InputMismatchException('Invalid confirmation token');
+            throw new InputMismatchException(__('Invalid confirmation token'));
         }
 
         $customer->setConfirmation(null);
@@ -359,16 +359,16 @@ class AccountManagement implements AccountManagementInterface
         try {
             $customer = $this->customerRepository->get($username);
         } catch (NoSuchEntityException $e) {
-            throw new InvalidEmailOrPasswordException('Invalid login or password.', []);
+            throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
         }
 
         $hash = $this->customerRegistry->retrieveSecureData($customer->getId())->getPasswordHash();
         if (!$this->encryptor->validateHash($password, $hash)) {
-            throw new InvalidEmailOrPasswordException('Invalid login or password.', []);
+            throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
         }
 
         if ($customer->getConfirmation() && $this->isConfirmationRequired($customer)) {
-            throw new EmailNotConfirmedException('This account is not confirmed.', []);
+            throw new EmailNotConfirmedException(__('This account is not confirmed.'));
         }
 
         $this->eventManager->dispatch(
@@ -414,8 +414,10 @@ class AccountManagement implements AccountManagementInterface
                     break;
                 default:
                     throw new InputException(
-                        InputException::INVALID_FIELD_VALUE,
-                        ['value' => $template, 'fieldName' => 'email type']
+                        __(
+                            InputException::INVALID_FIELD_VALUE,
+                            ['value' => $template, 'fieldName' => 'email type']
+                        )
                     );
             }
         } catch (MailException $e) {
@@ -490,7 +492,7 @@ class AccountManagement implements AccountManagementInterface
             $websiteId = $customer->getWebsiteId();
 
             if ($this->isCustomerInStore($websiteId, $customer->getStoreId())) {
-                throw new InputException('Customer already exists in this store.');
+                throw new InputException(__('Customer already exists in this store.'));
             }
             // Existing password hash will be used from secured customer data registry when saving customer
         }
@@ -509,7 +511,9 @@ class AccountManagement implements AccountManagementInterface
             // If customer exists existing hash will be used by Repository
             $customer = $this->customerRepository->save($customer, $hash);
         } catch (AlreadyExistsException $e) {
-            throw new InputMismatchException('Customer with the same email already exists in associated website.');
+            throw new InputMismatchException(
+                __('Customer with the same email already exists in associated website.')
+            );
         } catch (LocalizedException $e) {
             throw $e;
         }
@@ -582,7 +586,7 @@ class AccountManagement implements AccountManagementInterface
         try {
             $customer = $this->customerRepository->get($email);
         } catch (NoSuchEntityException $e) {
-            throw new InvalidEmailOrPasswordException('Invalid login or password.');
+            throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
         }
         return $this->changePasswordForCustomer($customer, $currentPassword, $newPassword);
     }
@@ -595,7 +599,7 @@ class AccountManagement implements AccountManagementInterface
         try {
             $customer = $this->customerRepository->getById($customerId);
         } catch (NoSuchEntityException $e) {
-            throw new InvalidEmailOrPasswordException('Invalid login or password.');
+            throw new InvalidEmailOrPasswordException(__('Invalid login or password.'));
         }
         return $this->changePasswordForCustomer($customer, $currentPassword, $newPassword);
     }
@@ -613,7 +617,8 @@ class AccountManagement implements AccountManagementInterface
         $customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
         $hash = $customerSecure->getPasswordHash();
         if (!$this->encryptor->validateHash($currentPassword, $hash)) {
-            throw new InvalidEmailOrPasswordException("Password doesn't match for this account.", []);
+            throw new InvalidEmailOrPasswordException(
+                __('Password doesn\'t match for this account.'));
         }
         $customerSecure->setRpToken(null);
         $customerSecure->setRpTokenCreatedAt(null);
@@ -642,12 +647,14 @@ class AccountManagement implements AccountManagementInterface
         $length = $this->stringHelper->strlen($password);
         if ($length < self::MIN_PASSWORD_LENGTH) {
             throw new InputException(
-                'The password must have at least %min_length characters.',
-                ['min_length' => self::MIN_PASSWORD_LENGTH]
+                __(
+                    'The password must have at least %1 characters.',
+                    self::MIN_PASSWORD_LENGTH
+                )
             );
         }
         if ($this->stringHelper->strlen(trim($password)) != $length) {
-            throw new InputException('The password can not begin or end with a space.');
+            throw new InputException(__('The password can not begin or end with a space.'));
         }
     }
 
@@ -742,11 +749,11 @@ class AccountManagement implements AccountManagementInterface
     {
         if (empty($customerId) || $customerId < 0) {
             $params = ['value' => $customerId, 'fieldName' => 'customerId'];
-            throw new InputException(InputException::INVALID_FIELD_VALUE, $params);
+            throw new InputException(__(InputException::INVALID_FIELD_VALUE, $params));
         }
         if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
             $params = ['fieldName' => 'resetPasswordLinkToken'];
-            throw new InputException(InputException::REQUIRED_FIELD, $params);
+            throw new InputException(__(InputException::REQUIRED_FIELD, $params));
         }
 
         $customerSecureData = $this->customerRegistry->retrieveSecureData($customerId);
@@ -754,9 +761,9 @@ class AccountManagement implements AccountManagementInterface
         $rpTokenCreatedAt = $customerSecureData->getRpTokenCreatedAt();
 
         if (strcmp($rpToken, $resetPasswordLinkToken) !== 0) {
-            throw new InputMismatchException('Reset password token mismatch.');
+            throw new InputMismatchException(__('Reset password token mismatch.'));
         } elseif ($this->isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)) {
-            throw new ExpiredException('Reset password token expired.');
+            throw new ExpiredException(__('Reset password token expired.'));
         }
 
         return true;
@@ -1009,8 +1016,10 @@ class AccountManagement implements AccountManagementInterface
     {
         if (!is_string($passwordLinkToken) || empty($passwordLinkToken)) {
             throw new InputException(
-                InputException::INVALID_FIELD_VALUE,
-                ['value' => $passwordLinkToken, 'fieldName' => 'password reset token']
+                __(
+                    InputException::INVALID_FIELD_VALUE,
+                    ['value' => $passwordLinkToken, 'fieldName' => 'password reset token']
+                )
             );
         }
         if (is_string($passwordLinkToken) && !empty($passwordLinkToken)) {
@@ -1068,7 +1077,7 @@ class AccountManagement implements AccountManagementInterface
      */
     public function sendPasswordResetConfirmationEmail($customer)
     {
-        $storeId = $customer->getStoreId();
+        $storeId = $this->storeManager->getStore()->getId();
         if (!$storeId) {
             $storeId = $this->getWebsiteStoreId($customer);
         }
diff --git a/app/code/Magento/Customer/Model/CustomerRegistry.php b/app/code/Magento/Customer/Model/CustomerRegistry.php
index cc4ea04078b95398a7ab715b76552df2e4f843a2..a6bd4bfc5705e7cbd94897610726c3c5b4c5c801 100644
--- a/app/code/Magento/Customer/Model/CustomerRegistry.php
+++ b/app/code/Magento/Customer/Model/CustomerRegistry.php
@@ -119,13 +119,15 @@ class CustomerRegistry
         if (!$customer->getEmail()) {
             // customer does not exist
             throw new NoSuchEntityException(
-                NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-                [
+                __(
+                    NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                    [
                     'fieldName' => 'email',
-                    'fieldValue' => $customerEmail,
-                    'field2Name' => 'websiteId',
-                    'field2Value' => $websiteId,
-                ]
+                        'fieldValue' => $customerEmail,
+                        'field2Name' => 'websiteId',
+                        'field2Value' => $websiteId,
+                    ]
+                )
             );
         } else {
             $this->customerRegistryById[$customer->getId()] = $customer;
diff --git a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php
index 0095cb509e2ee4c0ae8419327f4d1507961a841f..31a62c6e527d182b19050ad4fb979bc3499b41db 100644
--- a/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php
+++ b/app/code/Magento/Customer/Model/Metadata/AddressMetadata.php
@@ -78,13 +78,15 @@ class AddressMetadata implements AddressMetadataInterface
             return $attributeMetadata;
         } else {
             throw new NoSuchEntityException(
-                NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-                [
-                    'fieldName' => 'entityType',
-                    'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS,
-                    'field2Name' => 'attributeCode',
-                    'field2Value' => $attributeCode,
-                ]
+                __(
+                    NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                    [
+                        'fieldName' => 'entityType',
+                        'fieldValue' => AddressMetadataInterface::ENTITY_TYPE_ADDRESS,
+                        'field2Name' => 'attributeCode',
+                        'field2Value' => $attributeCode,
+                    ]
+                )
             );
         }
     }
diff --git a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php
index 91c017f2c3726fbca7e1c088d2ae12c4318b8f20..074561544878130aa63d015151e83e9f6c8a7106 100644
--- a/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php
+++ b/app/code/Magento/Customer/Model/Metadata/CustomerMetadata.php
@@ -78,13 +78,15 @@ class CustomerMetadata implements CustomerMetadataInterface
             return $attributeMetadata;
         } else {
             throw new NoSuchEntityException(
-                NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-                [
-                    'fieldName' => 'entityType',
-                    'fieldValue' => self::ENTITY_TYPE_CUSTOMER,
-                    'field2Name' => 'attributeCode',
-                    'field2Value' => $attributeCode,
-                ]
+                __(
+                    NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                    [
+                        'fieldName' => 'entityType',
+                        'fieldValue' => self::ENTITY_TYPE_CUSTOMER,
+                        'field2Name' => 'attributeCode',
+                        'field2Value' => $attributeCode,
+                    ]
+                )
             );
         }
     }
diff --git a/app/code/Magento/Customer/Model/Resource/Address.php b/app/code/Magento/Customer/Model/Resource/Address.php
index 3fbe59955af8a57d7f69fe27f2070a2df37d5bca..57a5c1cbcf3d9c28e975a999395d5ffd18600696 100644
--- a/app/code/Magento/Customer/Model/Resource/Address.php
+++ b/app/code/Magento/Customer/Model/Resource/Address.php
@@ -99,16 +99,15 @@ class Address extends \Magento\Eav\Model\Entity\AbstractEntity
      *
      * @param \Magento\Framework\Object $address
      * @return void
-     * @throws \Magento\Framework\Validator\ValidatorException When validation failed
+     * @throws \Magento\Framework\Validator\Exception When validation failed
      */
     protected function _validate($address)
     {
         $validator = $this->_validatorFactory->createValidator('customer_address', 'save');
 
         if (!$validator->isValid($address)) {
-            throw new \Magento\Framework\Validator\ValidatorException(
-                InputException::DEFAULT_MESSAGE,
-                [],
+            throw new \Magento\Framework\Validator\Exception(
+                null,
                 null,
                 $validator->getMessages()
             );
diff --git a/app/code/Magento/Customer/Model/Resource/AddressRepository.php b/app/code/Magento/Customer/Model/Resource/AddressRepository.php
index ce60b52c51c20722c26ab4bbf8c23dfcb8c521e2..54f51092c34cdfec9042dee1c36f9c9b50466368 100644
--- a/app/code/Magento/Customer/Model/Resource/AddressRepository.php
+++ b/app/code/Magento/Customer/Model/Resource/AddressRepository.php
@@ -248,41 +248,41 @@ class AddressRepository implements \Magento\Customer\Api\AddressRepositoryInterf
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getFirstname(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getLastname(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getStreetLine(1), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'street']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'street']));
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getCity(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'city']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'city']));
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getTelephone(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'telephone']));
         }
 
         $havingOptionalZip = $this->directoryData->getCountriesWithOptionalZip();
         if (!in_array($customerAddressModel->getCountryId(), $havingOptionalZip)
             && !\Zend_Validate::is($customerAddressModel->getPostcode(), 'NotEmpty')
         ) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']));
         }
 
         if (!\Zend_Validate::is($customerAddressModel->getCountryId(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'countryId']));
         }
 
         if ($customerAddressModel->getCountryModel()->getRegionCollection()->getSize()
             && !\Zend_Validate::is($customerAddressModel->getRegionId(), 'NotEmpty')
             && $this->directoryData->isRegionRequired($customerAddressModel->getCountryId())
         ) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'regionId']));
         }
 
         return $exception;
diff --git a/app/code/Magento/Customer/Model/Resource/Customer.php b/app/code/Magento/Customer/Model/Resource/Customer.php
index 9e14f1091ccb5954da6fd2663967ea7e466b2619..ae27ce56ce01b89308ca7a562d05448b34c95c54 100644
--- a/app/code/Magento/Customer/Model/Resource/Customer.php
+++ b/app/code/Magento/Customer/Model/Resource/Customer.php
@@ -5,7 +5,7 @@
  */
 namespace Magento\Customer\Model\Resource;
 
-use Magento\Framework\Validator\ValidatorException;
+use Magento\Framework\Validator\Exception as ValidatorException;
 use Magento\Framework\Exception\AlreadyExistsException;
 
 /**
@@ -131,7 +131,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity
      *
      * @param \Magento\Customer\Model\Customer $customer
      * @return void
-     * @throws \Magento\Framework\Validator\ValidatorException
+     * @throws \Magento\Framework\Validator\Exception
      */
     protected function _validate($customer)
     {
@@ -139,8 +139,7 @@ class Customer extends \Magento\Eav\Model\Entity\AbstractEntity
 
         if (!$validator->isValid($customer)) {
             throw new ValidatorException(
-                ValidatorException::DEFAULT_MESSAGE,
-                [],
+                null,
                 null,
                 $validator->getMessages()
             );
diff --git a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php
index 757ef49198d792f77de17761bd01f7d30e67e8b4..58adabf2ba9b0bccd93e69bf39da32a2226ef966 100644
--- a/app/code/Magento/Customer/Model/Resource/CustomerRepository.php
+++ b/app/code/Magento/Customer/Model/Resource/CustomerRepository.php
@@ -283,11 +283,11 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
     {
         $exception = new InputException();
         if (!\Zend_Validate::is(trim($customer->getFirstname()), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
         }
 
         if (!\Zend_Validate::is(trim($customer->getLastname()), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
         }
 
         $isEmailAddress = \Zend_Validate::is(
@@ -298,24 +298,26 @@ class CustomerRepository implements \Magento\Customer\Api\CustomerRepositoryInte
 
         if (!$isEmailAddress) {
             $exception->addError(
-                InputException::INVALID_FIELD_VALUE,
-                ['fieldName' => 'email', 'value' => $customer->getEmail()]
+                __(
+                    InputException::INVALID_FIELD_VALUE,
+                    ['fieldName' => 'email', 'value' => $customer->getEmail()]
+                )
             );
         }
 
         $dob = $this->getAttributeMetadata('dob');
         if (!is_null($dob) && $dob->isRequired() && '' == trim($customer->getDob())) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'dob']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'dob']));
         }
 
         $taxvat = $this->getAttributeMetadata('taxvat');
         if (!is_null($taxvat) && $taxvat->isRequired() && '' == trim($customer->getTaxvat())) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat']));
         }
 
         $gender = $this->getAttributeMetadata('gender');
         if (!is_null($gender) && $gender->isRequired() && '' == trim($customer->getGender())) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'gender']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'gender']));
         }
 
         if ($exception->wasErrorAdded()) {
diff --git a/app/code/Magento/Customer/Model/Resource/GroupRepository.php b/app/code/Magento/Customer/Model/Resource/GroupRepository.php
index 74f227df9ebf71c99d6b4765cd41530dda28d63f..73b59ff2dd1e54166d149019ae8585076b46b37d 100644
--- a/app/code/Magento/Customer/Model/Resource/GroupRepository.php
+++ b/app/code/Magento/Customer/Model/Resource/GroupRepository.php
@@ -125,7 +125,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface
              *  difficult to do without imposing more database calls
              */
             if ($e->getMessage() == (string)__('Customer Group already exists.')) {
-                throw new InvalidTransitionException('Customer Group already exists.');
+                throw new InvalidTransitionException(__('Customer Group already exists.'));
             }
             throw $e;
         }
@@ -266,7 +266,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface
         $groupModel = $this->groupRegistry->retrieve($id);
 
         if ($id <= 0 || $groupModel->usesAsDefault()) {
-            throw new \Magento\Framework\Exception\StateException('Cannot delete group.');
+            throw new \Magento\Framework\Exception\StateException(__('Cannot delete group.'));
         }
 
         $groupModel->delete();
@@ -288,7 +288,7 @@ class GroupRepository implements \Magento\Customer\Api\GroupRepositoryInterface
     {
         $exception = new InputException();
         if (!\Zend_Validate::is($group->getCode(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'code']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'code']));
         }
 
         if ($exception->wasErrorAdded()) {
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php
index 54babee0fd4231e4ec44b7709f4616d216dfda4f..feaf248f233fed187703debc236d69e4d696d821 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Account/Dashboard/InfoTest.php
@@ -133,15 +133,15 @@ class InfoTest extends \PHPUnit_Framework_TestCase
 
     public function testGetCustomerException()
     {
-        $this->currentCustomer->expects(
-            $this->once()
-        )->method(
-                'getCustomer'
-            )->will($this->throwException(new NoSuchEntityException(
+        $this->currentCustomer->expects($this->once())
+            ->method('getCustomer')
+            ->will(
+                $this->throwException(new NoSuchEntityException(
+                    __(
                         NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                         ['fieldName' => 'customerId', 'fieldValue' => 1]
                     )
-                )
+                ))
             );
 
         $this->assertNull($this->_block->getCustomer());
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
index 347ad1ee35a4f2e2816c1a42204aa6968d02740e..5d1e91708b4fcd6da306011c551415bf3586d66a 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/DobTest.php
@@ -118,16 +118,15 @@ class DobTest extends \PHPUnit_Framework_TestCase
 
     public function testIsEnabledWithException()
     {
-        $this->customerMetadata->expects(
-            $this->any()
-        )->method(
-                'getAttributeMetadata'
-            )->will(
+        $this->customerMetadata->expects($this->any())
+            ->method('getAttributeMetadata')
+            ->will(
                 $this->throwException(new NoSuchEntityException(
+                    __(
                         NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                         ['fieldName' => 'field', 'fieldValue' => 'value']
                     )
-                )
+                ))
             );
         $this->assertSame(false, $this->_block->isEnabled());
     }
@@ -146,16 +145,15 @@ class DobTest extends \PHPUnit_Framework_TestCase
 
     public function testIsRequiredWithException()
     {
-        $this->customerMetadata->expects(
-            $this->any()
-        )->method(
-                'getAttributeMetadata'
-            )->will(
+        $this->customerMetadata->expects($this->any())
+            ->method('getAttributeMetadata')
+            ->will(
                 $this->throwException(new NoSuchEntityException(
+                    __(
                         NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                         ['fieldName' => 'field', 'fieldValue' => 'value']
                     )
-                )
+                ))
             );
         $this->assertSame(false, $this->_block->isRequired());
     }
@@ -346,16 +344,15 @@ class DobTest extends \PHPUnit_Framework_TestCase
 
     public function testGetMinDateRangeWithException()
     {
-        $this->customerMetadata->expects(
-            $this->any()
-        )->method(
-                'getAttributeMetadata'
-            )->will(
+        $this->customerMetadata->expects($this->any())
+            ->method('getAttributeMetadata')
+            ->will(
                 $this->throwException(new NoSuchEntityException(
+                    __(
                         NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                         ['fieldName' => 'field', 'fieldValue' => 'value']
                     )
-                )
+                ))
             );
         $this->assertNull($this->_block->getMinDateRange());
     }
@@ -416,16 +413,15 @@ class DobTest extends \PHPUnit_Framework_TestCase
 
     public function testGetMaxDateRangeWithException()
     {
-        $this->customerMetadata->expects(
-            $this->any()
-        )->method(
-                'getAttributeMetadata'
-            )->will(
+        $this->customerMetadata->expects($this->any())
+            ->method('getAttributeMetadata')
+            ->will(
                 $this->throwException(new NoSuchEntityException(
+                    __(
                         NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                         ['fieldName' => 'field', 'fieldValue' => 'value']
                     )
-                )
+                ))
             );
         $this->assertNull($this->_block->getMaxDateRange());
     }
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php
index 74ae91c3c4293cfaf022cefa6e94867eb87c0075..ed42e290f660c720620941122ef46e86a94ef0e7 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/GenderTest.php
@@ -94,10 +94,11 @@ class GenderTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertSame(false, $this->block->isEnabled());
     }
@@ -134,10 +135,11 @@ class GenderTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertSame(false, $this->block->isRequired());
     }
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php
index c58604088c81bbac849ef58b6f61f3d41cbc15d9..5f15f240fd977aba2ce1e7a0f32f061fc682d81c 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/NameTest.php
@@ -127,10 +127,11 @@ class NameTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertFalse($this->_block->showPrefix());
     }
@@ -147,10 +148,11 @@ class NameTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertFalse($this->_block->{$method}());
     }
@@ -395,10 +397,11 @@ class NameTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertSame('', (string)$this->_block->getStoreLabel('attributeCode'));
     }
diff --git a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php
index 474f6c42467aeab94cc08a8bf18a8a3044ca869d..356d748dab9db6d29f92eae976356cb1b25a7c78 100644
--- a/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Block/Widget/TaxvatTest.php
@@ -81,10 +81,11 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertSame(false, $this->_block->isEnabled());
     }
@@ -118,10 +119,11 @@ class TaxvatTest extends \PHPUnit_Framework_TestCase
             'getAttributeMetadata'
         )->will(
             $this->throwException(new NoSuchEntityException(
+                __(
                     NoSuchEntityException::MESSAGE_SINGLE_FIELD,
                     ['fieldName' => 'field', 'fieldValue' => 'value']
                 )
-            )
+            ))
         );
         $this->assertSame(false, $this->_block->isRequired());
     }
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..86113cef969df40aa3c6f1f1f1603acca0f148b2
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/EditPostTest.php
@@ -0,0 +1,408 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+namespace Magento\Customer\Test\Unit\Controller\Account;
+
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class EditPostTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Framework\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $context;
+
+    /**
+     * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $customerSession;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resultRedirectFactory;
+
+    /**
+     * @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $resultPageFactory;
+
+    /**
+     * @var \Magento\Customer\Api\AccountManagementInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $customerAccountManagement;
+
+    /**
+     * @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $customerRepository;
+
+    /**
+     * @var \Magento\Framework\Data\Form\FormKey\Validator|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $formKeyValidator;
+
+    /**
+     * @var \Magento\Customer\Model\CustomerExtractor|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $customerExtractor;
+
+    /**
+     * @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $redirectResultMock;
+
+    /**
+     * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $response;
+
+    /**
+     * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $request;
+
+    /**
+     * @var \Magento\TestFramework\Helper\ObjectManager|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $objectManager;
+
+    /**
+     * @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $customer;
+
+    /**
+     * @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $messageManager;
+
+    public function setUp()
+    {
+        $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+
+        $this->response = $this->getMock('Magento\Framework\App\ResponseInterface', [], [], '', false);
+        $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false);
+
+        $this->messageManager = $this->getMock('Magento\Framework\Message\Manager', [], [], '', false);
+
+        $this->context = $this->objectManager->getObject(
+            'Magento\Framework\App\Action\Context',
+            [
+                'request' => $this->request,
+                'response' => $this->response,
+                'messageManager' => $this->messageManager
+            ]
+        );
+
+        $this->redirectResultMock = $this->getMock('Magento\Framework\Controller\Result\Redirect', [], [], '', false);
+        $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false);
+        $this->resultRedirectFactory = $this->getMock(
+            'Magento\Framework\Controller\Result\RedirectFactory',
+            ['create'],
+            [],
+            '',
+            false
+        );
+        $this->resultPageFactory = $this->getMock('Magento\Framework\View\Result\PageFactory', [], [], '', false);
+        $this->customerAccountManagement = $this->getMockForAbstractClass(
+            'Magento\Customer\Api\AccountManagementInterface',
+            [],
+            '',
+            false
+        );
+        $this->customerRepository = $this->getMockForAbstractClass(
+            'Magento\Customer\Api\CustomerRepositoryInterface',
+            [],
+            '',
+            false
+        );
+        $this->formKeyValidator = $this->getMock('Magento\Framework\Data\Form\FormKey\Validator', [], [], '', false);
+        $this->customerExtractor = $this->getMock('Magento\Customer\Model\CustomerExtractor', [], [], '', false);
+        $this->customer = $this->getMockForAbstractClass(
+            'Magento\Customer\Api\Data\CustomerInterface',
+            [],
+            'dataCustomer',
+            false
+        );
+    }
+
+    /**
+     * @return \Magento\Customer\Controller\Account\EditPost
+     */
+    public function getController()
+    {
+        return $this->objectManager->getObject(
+            'Magento\Customer\Controller\Account\EditPost',
+            [
+                'context' => $this->context,
+                'customerSession' => $this->customerSession,
+                'resultRedirectFactory' => $this->resultRedirectFactory,
+                'resultPageFactory' => $this->resultPageFactory,
+                'customerAccountManagement' => $this->customerAccountManagement,
+                'customerRepository' => $this->customerRepository,
+                'formKeyValidator' => $this->formKeyValidator,
+                'customerExtractor' => $this->customerExtractor
+            ]
+        );
+    }
+
+    public function testEditPostActionWithInvalidFormKey()
+    {
+        $this->resultRedirectFactory
+            ->expects($this->once())
+            ->method('create')
+            ->willReturn($this->redirectResultMock);
+        $this->formKeyValidator
+            ->expects($this->once())
+            ->method('validate')
+            ->willReturn(false);
+        $this->redirectResultMock
+            ->expects($this->once())
+            ->method('setPath')
+            ->with('*/*/edit')
+            ->willReturn('http://test.com/customer/account/edit');
+
+        $this->assertSame($this->redirectResultMock, $this->getController()->execute());
+    }
+
+    /**
+     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+     */
+    public function testEditPostActionWithAuthenticationExceptionWhenTryingChangePassword()
+    {
+        $customerId = 24;
+        $address = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false);
+        $loadedCustomer = $this->getMockForAbstractClass(
+            'Magento\Customer\Api\Data\CustomerInterface',
+            [],
+            'loadedCustomer',
+            false
+        );
+
+        $loadedCustomer
+            ->expects($this->once())
+            ->method('getAddresses')
+            ->willReturn([$address, $address]);
+
+        $this->resultRedirectFactory
+            ->expects($this->once())
+            ->method('create')
+            ->willReturn($this->redirectResultMock);
+        $this->formKeyValidator
+            ->expects($this->once())
+            ->method('validate')
+            ->willReturn(true);
+        $this->request
+            ->expects($this->once())
+            ->method('isPost')
+            ->willReturn(true);
+
+        $this->customerSession
+            ->expects($this->once())
+            ->method('getCustomerId')
+            ->willReturn($customerId);
+        $this->customerExtractor
+            ->expects($this->once())
+            ->method('extract')
+            ->willReturn($this->customer);
+        $this->customer
+            ->expects($this->once())
+            ->method('setId')
+            ->with($customerId);
+        $this->customer
+            ->expects($this->once())
+            ->method('getAddresses')
+            ->willReturn(null);
+        $this->customerRepository
+            ->expects($this->exactly(2))
+            ->method('getById')
+            ->with($customerId)
+            ->willReturn($loadedCustomer);
+        $this->customer
+            ->expects($this->once())
+            ->method('setAddresses')
+            ->with([$address, $address]);
+        $this->request
+            ->expects($this->once())
+            ->method('getParam')
+            ->with('change_password')
+            ->willReturn(true);
+
+        $this->request
+            ->expects($this->at(2))
+            ->method('getPost')
+            ->with('current_password', null)
+            ->willReturn(123);
+        $this->request
+            ->expects($this->at(3))
+            ->method('getPost')
+            ->with('password', null)
+            ->willReturn(321);
+        $this->request
+            ->expects($this->at(4))
+            ->method('getPost')
+            ->with('password_confirmation', null)
+            ->willReturn(321);
+
+        $this->customerAccountManagement
+            ->expects($this->once())
+            ->method('changePassword')
+            ->willThrowException(new \Magento\Framework\Exception\AuthenticationException(__('Error')));
+        $this->messageManager
+            ->expects($this->once())
+            ->method('addError')
+            ->with('Error');
+
+        $exception = new \Magento\Framework\Exception\InputException(__('Error'));
+        $this->customerRepository
+            ->expects($this->once())
+            ->method('save')
+            ->willThrowException($exception);
+        $this->messageManager
+            ->expects($this->once())
+            ->method('addException')
+            ->with($exception, 'Invalid input');
+        $this->request
+            ->expects($this->once())
+            ->method('getPostValue')
+            ->willReturn([]);
+
+        $messageCollection = $this->getMock('Magento\Framework\Message\Collection', [], [], '', false);
+        $messageCollection
+            ->expects($this->once())
+            ->method('getCount')
+            ->willReturn(3);
+        $this->messageManager
+            ->expects($this->once())
+            ->method('getMessages')
+            ->willReturn($messageCollection);
+        $this->customerSession
+            ->expects($this->once())
+            ->method('__call')
+            ->with('setCustomerFormData', [[]]);
+
+        $this->redirectResultMock
+            ->expects($this->once())
+            ->method('setPath')
+            ->with('*/*/edit')
+            ->willReturn('http://test.com/customer/account/edit');
+
+        $this->assertSame($this->redirectResultMock, $this->getController()->execute());
+    }
+
+    /**
+     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+     */
+    public function testEditPostActionWithoutErrors()
+    {
+        $customerId = 24;
+        $address = $this->getMockForAbstractClass('Magento\Customer\Api\Data\AddressInterface', [], '', false);
+        $loadedCustomer = $this->getMockForAbstractClass(
+            'Magento\Customer\Api\Data\CustomerInterface',
+            [],
+            'loadedCustomer',
+            false
+        );
+
+        $loadedCustomer
+            ->expects($this->once())
+            ->method('getAddresses')
+            ->willReturn([$address, $address]);
+
+        $this->resultRedirectFactory
+            ->expects($this->once())
+            ->method('create')
+            ->willReturn($this->redirectResultMock);
+        $this->formKeyValidator
+            ->expects($this->once())
+            ->method('validate')
+            ->willReturn(true);
+        $this->request
+            ->expects($this->once())
+            ->method('isPost')
+            ->willReturn(true);
+
+        $this->customerSession
+            ->expects($this->once())
+            ->method('getCustomerId')
+            ->willReturn($customerId);
+        $this->customerExtractor
+            ->expects($this->once())
+            ->method('extract')
+            ->willReturn($this->customer);
+        $this->customer
+            ->expects($this->once())
+            ->method('setId')
+            ->with($customerId);
+        $this->customer
+            ->expects($this->once())
+            ->method('getAddresses')
+            ->willReturn(null);
+        $this->customerRepository
+            ->expects($this->exactly(2))
+            ->method('getById')
+            ->with($customerId)
+            ->willReturn($loadedCustomer);
+        $this->customer
+            ->expects($this->once())
+            ->method('setAddresses')
+            ->with([$address, $address]);
+        $this->request
+            ->expects($this->once())
+            ->method('getParam')
+            ->with('change_password')
+            ->willReturn(true);
+
+        $this->request
+            ->expects($this->at(2))
+            ->method('getPost')
+            ->with('current_password', null)
+            ->willReturn(123);
+        $this->request
+            ->expects($this->at(3))
+            ->method('getPost')
+            ->with('password', null)
+            ->willReturn(321);
+        $this->request
+            ->expects($this->at(4))
+            ->method('getPost')
+            ->with('password_confirmation', null)
+            ->willReturn(321);
+
+        $this->customerAccountManagement
+            ->expects($this->once())
+            ->method('changePassword');
+
+        $this->customerRepository
+            ->expects($this->once())
+            ->method('save');
+
+        $messageCollection = $this->getMock('Magento\Framework\Message\Collection', [], [], '', false);
+        $messageCollection
+            ->expects($this->once())
+            ->method('getCount')
+            ->willReturn(0);
+        $this->messageManager
+            ->expects($this->once())
+            ->method('getMessages')
+            ->willReturn($messageCollection);
+
+        $this->messageManager
+            ->expects($this->once())
+            ->method('addSuccess')
+            ->with('The account information has been saved.');
+
+        $this->redirectResultMock
+            ->expects($this->once())
+            ->method('setPath')
+            ->with('customer/account')
+            ->willReturn('http://test.com/customer/account/edit');
+
+        $this->assertSame($this->redirectResultMock, $this->getController()->execute());
+    }
+}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
index 6f670e3e8ed8fdec1369ba50a78ef712cdec7713..7837c811df305141807f92c816cc06155298ee00 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php
@@ -96,6 +96,9 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase
      */
     protected $_formKeyValidator;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->request = $this->getMockBuilder('Magento\Framework\App\Request\Http')
@@ -170,6 +173,7 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase
 
     /**
      * covers \Magento\Customer\Controller\Account::getAllowedActions
+     * @return void
      */
     public function testGetAllowedActions()
     {
@@ -182,31 +186,4 @@ class LoginPostTest extends \PHPUnit_Framework_TestCase
         $method->setAccessible(true);
         $this->assertEquals($this->openActions, $method->invoke($this->object));
     }
-
-    public function testLoginPostActionWhenRefererSetBeforeAuthUrl()
-    {
-        $this->_formKeyValidator->expects($this->once())->method('validate')->will($this->returnValue(true));
-        $this->customerSession->expects($this->at(0))->method('isLoggedIn')->with()->will($this->returnValue(0));
-        $this->customerSession->expects($this->at(4))->method('isLoggedIn')->with()->will($this->returnValue(1));
-        $this->request->expects(
-            $this->once()
-        )->method(
-            'getParam'
-        )->with(
-            Url::REFERER_QUERY_PARAM_NAME
-        )->will(
-            $this->returnValue('referer')
-        );
-        $this->url->expects($this->once())->method('isOwnOriginUrl')->with();
-
-        $this->redirectFactoryMock->expects($this->once())
-            ->method('create')
-            ->willReturn($this->redirectResultMock);
-
-        $this->redirectResultMock->expects($this->once())
-            ->method('setUrl')
-            ->willReturnSelf();
-
-        $this->object->execute();
-    }
 }
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php
index 10056504ec33f3fba2f7efaee609ee226dd13a25..53ffa02b353e2fdb921a19e0b1f52063359ac365 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/ResetPasswordTest.php
@@ -281,8 +281,10 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase
         )->will(
             $this->throwException(
                 new NoSuchEntityException(
-                    NoSuchEntityException::MESSAGE_SINGLE_FIELD,
-                    ['fieldName' => 'customerId', 'fieldValue' => $customerId]
+                    __(
+                        NoSuchEntityException::MESSAGE_SINGLE_FIELD,
+                        ['fieldName' => 'customerId', 'fieldValue' => $customerId]
+                    )
                 )
             )
         );
@@ -324,7 +326,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase
         );
 
         // Setup a core exception to return
-        $exception = new \Magento\Framework\Validator\ValidatorException();
+        $exception = new \Magento\Framework\Validator\Exception();
         $error = new \Magento\Framework\Message\Error('Something Bad happened');
         $exception->addMessage($error);
 
@@ -357,7 +359,7 @@ class ResetPasswordTest extends \PHPUnit_Framework_TestCase
             ->willReturn($customerId);
 
         // Setup a core exception to return
-        $exception = new \Magento\Framework\Validator\ValidatorException($warningText);
+        $exception = new \Magento\Framework\Validator\Exception(__($warningText));
 
         $error = new \Magento\Framework\Message\Warning('Something Not So Bad happened');
         $exception->addMessage($error);
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php
old mode 100644
new mode 100755
index ed14df9d4b7776c3e24239cf46a57b4aaa9fac5c..55518d9fab215f8d19bba5576e326393153add2b
--- a/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Ajax/LoginTest.php
@@ -51,12 +51,12 @@ class LoginTest extends \PHPUnit_Framework_TestCase
     protected $jsonHelperMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJson;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory| \PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory| \PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactory;
 
@@ -114,10 +114,10 @@ class LoginTest extends \PHPUnit_Framework_TestCase
             false
         );
 
-        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->getMock();
-        $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -238,7 +238,7 @@ class LoginTest extends \PHPUnit_Framework_TestCase
             ->expects($this->any())
             ->method('authenticate')
             ->with('invalid@example.com', 'invalid')
-            ->willThrowException(new InvalidEmailOrPasswordException('Invalid login or password.', []));
+            ->willThrowException(new InvalidEmailOrPasswordException(__('Invalid login or password.')));
 
         $this->customerSession->expects($this->never())
             ->method('setCustomerDataAsLoggedIn')
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..367865649d761cc77fddfdf9675218af3e943e81
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Unit/Model/Account/RedirectTest.php
@@ -0,0 +1,265 @@
+<?php
+/**
+ * Unit test for Magento\Customer\Test\Unit\Model\Account\Redirect
+ *
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+// @codingStandardsIgnoreFile
+
+namespace Magento\Customer\Test\Unit\Model\Account;
+
+use Magento\Customer\Model\Account\Redirect;
+use Magento\Customer\Model\Url as CustomerUrl;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+
+class RedirectTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var Redirect
+     */
+    protected $model;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\RequestInterface
+     */
+    protected $request;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Session
+     */
+    protected $customerSession;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\App\Config\ScopeConfigInterface
+     */
+    protected $scopeConfig;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\StoreManagerInterface
+     */
+    protected $storeManager;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Store\Model\Store
+     */
+    protected $store;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\UrlInterface
+     */
+    protected $url;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Url\DecoderInterface
+     */
+    protected $urlDecoder;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Customer\Model\Url
+     */
+    protected $customerUrl;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Controller\Result\Redirect
+     */
+    protected $resultRedirect;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject | \Magento\Framework\Controller\Result\RedirectFactory
+     */
+    protected $resultRedirectFactory;
+
+    public function setUp()
+    {
+        $this->request = $this->getMockForAbstractClass('Magento\Framework\App\RequestInterface');
+
+        $this->customerSession = $this->getMockBuilder('Magento\Customer\Model\Session')
+            ->disableOriginalConstructor()
+            ->setMethods([
+                'getLastCustomerId',
+                'isLoggedIn',
+                'getId',
+                'setLastCustomerId',
+                'unsBeforeAuthUrl',
+                'getBeforeAuthUrl',
+                'setBeforeAuthUrl',
+                'getAfterAuthUrl',
+                'setAfterAuthUrl',
+            ])
+            ->getMock();
+
+        $this->scopeConfig = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface');
+
+        $this->store = $this->getMockBuilder('Magento\Store\Model\Store')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->storeManager = $this->getMockForAbstractClass('Magento\Store\Model\StoreManagerInterface');
+        $this->storeManager->expects($this->once())
+            ->method('getStore')
+            ->willReturn($this->store);
+
+        $this->url = $this->getMockForAbstractClass('Magento\Framework\UrlInterface');
+        $this->urlDecoder = $this->getMockForAbstractClass('Magento\Framework\Url\DecoderInterface');
+
+        $this->customerUrl = $this->getMockBuilder('Magento\Customer\Model\Url')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->resultRedirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->resultRedirectFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\RedirectFactory')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->resultRedirectFactory->expects($this->once())
+            ->method('create')
+            ->willReturn($this->resultRedirect);
+
+        $objectManager = new ObjectManager($this);
+        $this->model = $objectManager->getObject(
+            'Magento\Customer\Model\Account\Redirect',
+            [
+                'request'               => $this->request,
+                'customerSession'       => $this->customerSession,
+                'scopeConfig'           => $this->scopeConfig,
+                'storeManager'          => $this->storeManager,
+                'url'                   => $this->url,
+                'urlDecoder'            => $this->urlDecoder,
+                'customerUrl'           => $this->customerUrl,
+                'resultRedirectFactory' => $this->resultRedirectFactory
+            ]
+        );
+    }
+
+    /**
+     * @dataProvider getRedirectDataProvider
+     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
+     */
+    public function testGetRedirect(
+        $customerId,
+        $lastCustomerId,
+        $referer,
+        $baseUrl,
+        $beforeAuthUrl,
+        $afterAuthUrl,
+        $accountUrl,
+        $loginUrl,
+        $logoutUrl,
+        $dashboardUrl,
+        $customerLoggedIn,
+        $redirectToDashboard
+    ) {
+        // Preparations for method updateLastCustomerId()
+        $this->customerSession->expects($this->once())
+            ->method('getLastCustomerId')
+            ->willReturn($customerId);
+        $this->customerSession->expects($this->any())
+            ->method('isLoggedIn')
+            ->willReturn($customerLoggedIn);
+        $this->customerSession->expects($this->any())
+            ->method('getId')
+            ->willReturn($lastCustomerId);
+        $this->customerSession->expects($this->any())
+            ->method('unsBeforeAuthUrl')
+            ->willReturnSelf();
+        $this->customerSession->expects($this->any())
+            ->method('setLastCustomerId')
+            ->with($lastCustomerId)
+            ->willReturnSelf();
+
+        // Preparations for method prepareRedirectUrl()
+        $this->store->expects($this->once())
+            ->method('getBaseUrl')
+            ->willReturn($baseUrl);
+
+        $this->customerSession->expects($this->any())
+            ->method('getBeforeAuthUrl')
+            ->willReturn($beforeAuthUrl);
+        $this->customerSession->expects($this->any())
+            ->method('setBeforeAuthUrl')
+            ->willReturnSelf();
+        $this->customerSession->expects($this->any())
+            ->method('getAfterAuthUrl')
+            ->willReturn($afterAuthUrl);
+        $this->customerSession->expects($this->any())
+            ->method('setAfterAuthUrl')
+            ->with($beforeAuthUrl)
+            ->willReturnSelf();
+
+        $this->customerUrl->expects($this->any())
+            ->method('getAccountUrl')
+            ->willReturn($accountUrl);
+        $this->customerUrl->expects($this->any())
+            ->method('getLoginUrl')
+            ->willReturn($loginUrl);
+        $this->customerUrl->expects($this->any())
+            ->method('getLogoutUrl')
+            ->willReturn($logoutUrl);
+        $this->customerUrl->expects($this->any())
+            ->method('DashboardUrl')
+            ->willReturn($dashboardUrl);
+
+        $this->scopeConfig->expects($this->any())
+            ->method('isSetFlag')
+            ->with(CustomerUrl::XML_PATH_CUSTOMER_STARTUP_REDIRECT_TO_DASHBOARD, ScopeInterface::SCOPE_STORE)
+            ->willReturn($redirectToDashboard);
+
+        $this->request->expects($this->any())
+            ->method('getParam')
+            ->with(CustomerUrl::REFERER_QUERY_PARAM_NAME)
+            ->willReturn($referer);
+
+        $this->urlDecoder->expects($this->any())
+            ->method('decode')
+            ->with($referer)
+            ->willReturn($referer);
+
+        $this->url->expects($this->any())
+            ->method('isOwnOriginUrl')
+            ->willReturn(true);
+
+        $this->resultRedirect->expects($this->once())
+            ->method('setUrl')
+            ->willReturnSelf();
+
+        $this->model->getRedirect();
+    }
+
+    /**
+     * @return array
+     */
+    public function getRedirectDataProvider()
+    {
+        /**
+         * Customer ID
+         * Last customer ID
+         * Referer
+         * Base URL
+         * BeforeAuth URL
+         * AfterAuth URL
+         * Account URL
+         * Login URL
+         * Logout URL
+         * Dashboard URL
+         * Is customer logged in flag
+         * Redirect to Dashboard flag
+         */
+        return [
+            // Loggend In, Redirect by Referer
+            [1, 2, 'referer', 'base', '', '', 'account', '', '', '', true, false],
+            // Loggend In, Redirect by AfterAuthUrl
+            [1, 2, 'referer', 'base', '', 'defined', 'account', '', '', '', true, true],
+            // Not logged In, Redirect by LoginUrl
+            [1, 2, 'referer', 'base', '', '', 'account', 'login', '', '', false, true],
+            // Logout, Redirect to Dashboard
+            [1, 2, 'referer', 'base', 'logout', '', 'account', 'login', 'logout', 'dashboard', false, true],
+            // Default redirect
+            [1, 2, 'referer', 'base', 'defined', '', 'account', 'login', 'logout', 'dashboard', true, true],
+        ];
+    }
+}
diff --git a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
index 54233608509d82a0bb112dc23682e5279c2ab1d7..1dc6754f3de9f173f9a8550c462b122cb8ab756a 100644
--- a/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
+++ b/app/code/Magento/DesignEditor/Model/Editor/Tools/QuickStyles/Form/Renderer/Factory.php
@@ -72,7 +72,7 @@ class Factory
     {
         if (!isset($this->_rendererByElement[$elementClassName])) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                sprintf('No renderer registered for elements of class "%s"', $elementClassName)
+                __('No renderer registered for elements of class "%1"', $elementClassName)
             );
         }
         $rendererClass = $this->_rendererByElement[$elementClassName];
diff --git a/app/code/Magento/Downloadable/Model/File/ContentValidator.php b/app/code/Magento/Downloadable/Model/File/ContentValidator.php
index 4f3293fc8be042c0309f1b4a94829f1a53829921..535ccab5bb459d6e1913e738c14749a0d09c20fc 100644
--- a/app/code/Magento/Downloadable/Model/File/ContentValidator.php
+++ b/app/code/Magento/Downloadable/Model/File/ContentValidator.php
@@ -21,11 +21,11 @@ class ContentValidator
     {
         $decodedContent = @base64_decode($fileContent->getFileData(), true);
         if (empty($decodedContent)) {
-            throw new InputException('Provided content must be valid base64 encoded data.');
+            throw new InputException(__('Provided content must be valid base64 encoded data.'));
         }
 
         if (!$this->isFileNameValid($fileContent->getName())) {
-            throw new InputException('Provided file name contains forbidden characters.');
+            throw new InputException(__('Provided file name contains forbidden characters.'));
         }
         return true;
     }
diff --git a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php
index 508536408a5e69e53af9d30d64cfe33038dbe68d..708302b7871c21c7bd1921b7a522019cbcd25aef 100644
--- a/app/code/Magento/Downloadable/Model/Link/ContentValidator.php
+++ b/app/code/Magento/Downloadable/Model/Link/ContentValidator.php
@@ -44,13 +44,13 @@ class ContentValidator
     public function isValid(LinkContentInterface $linkContent)
     {
         if (!is_numeric($linkContent->getPrice()) || $linkContent->getPrice() < 0) {
-            throw new InputException('Link price must have numeric positive value.');
+            throw new InputException(__('Link price must have numeric positive value.'));
         }
         if (!is_int($linkContent->getNumberOfDownloads()) || $linkContent->getNumberOfDownloads() < 0) {
-            throw new InputException('Number of downloads must be a positive integer.');
+            throw new InputException(__('Number of downloads must be a positive integer.'));
         }
         if (!is_int($linkContent->getSortOrder()) || $linkContent->getSortOrder() < 0) {
-            throw new InputException('Sort order must be a positive integer.');
+            throw new InputException(__('Sort order must be a positive integer.'));
         }
 
         $this->validateLinkResource($linkContent);
@@ -70,12 +70,12 @@ class ContentValidator
         if ($linkContent->getLinkType() == 'url'
             && !$this->urlValidator->isValid($linkContent->getLinkUrl())
         ) {
-            throw new InputException('Link URL must have valid format.');
+            throw new InputException(__('Link URL must have valid format.'));
         }
         if ($linkContent->getLinkType() == 'file'
             && (!$linkContent->getLinkFile() || !$this->fileContentValidator->isValid($linkContent->getLinkFile()))
         ) {
-            throw new InputException('Provided file content must be valid base64 encoded data.');
+            throw new InputException(__('Provided file content must be valid base64 encoded data.'));
         }
     }
 
@@ -91,12 +91,12 @@ class ContentValidator
         if ($linkContent->getSampleType() == 'url'
             && !$this->urlValidator->isValid($linkContent->getSampleUrl())
         ) {
-            throw new InputException('Sample URL must have valid format.');
+            throw new InputException(__('Sample URL must have valid format.'));
         }
         if ($linkContent->getSampleType() == 'file'
             && (!$linkContent->getSampleFile() || !$this->fileContentValidator->isValid($linkContent->getSampleFile()))
         ) {
-            throw new InputException('Provided file content must be valid base64 encoded data.');
+            throw new InputException(__('Provided file content must be valid base64 encoded data.'));
         }
     }
 }
diff --git a/app/code/Magento/Downloadable/Model/LinkRepository.php b/app/code/Magento/Downloadable/Model/LinkRepository.php
index 217e5ae59cea4f9dc81bfa6079a2bd49f1efc022..426e8bf63f21ed644dae4394470c8bf71d6482b4 100644
--- a/app/code/Magento/Downloadable/Model/LinkRepository.php
+++ b/app/code/Magento/Downloadable/Model/LinkRepository.php
@@ -189,13 +189,13 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac
             /** @var $link \Magento\Downloadable\Model\Link */
             $link = $this->linkFactory->create()->load($linkId);
             if (!$link->getId()) {
-                throw new NoSuchEntityException('There is no downloadable link with provided ID.');
+                throw new NoSuchEntityException(__('There is no downloadable link with provided ID.'));
             }
             if ($link->getProductId() != $product->getId()) {
-                throw new InputException('Provided downloadable link is not related to given product.');
+                throw new InputException(__('Provided downloadable link is not related to given product.'));
             }
             if (!$this->contentValidator->isValid($linkContent)) {
-                throw new InputException('Provided link information is invalid.');
+                throw new InputException(__('Provided link information is invalid.'));
             }
             if ($isGlobalScopeContent) {
                 $product->setStoreId(0);
@@ -203,7 +203,7 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac
             $title = $linkContent->getTitle();
             if (empty($title)) {
                 if ($isGlobalScopeContent) {
-                    throw new InputException('Link title cannot be empty.');
+                    throw new InputException(__('Link title cannot be empty.'));
                 }
                 // use title from GLOBAL scope
                 $link->setTitle(null);
@@ -224,18 +224,18 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac
         } else {
             $product = $this->productRepository->get($sku, true);
             if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
-                throw new InputException('Product type of the product must be \'downloadable\'.');
+                throw new InputException(__('Product type of the product must be \'downloadable\'.'));
             }
             if (!$this->contentValidator->isValid($linkContent)) {
-                throw new InputException('Provided link information is invalid.');
+                throw new InputException(__('Provided link information is invalid.'));
             }
 
             if (!in_array($linkContent->getLinkType(), ['url', 'file'])) {
-                throw new InputException('Invalid link type.');
+                throw new InputException(__('Invalid link type.'));
             }
             $title = $linkContent->getTitle();
             if (empty($title)) {
-                throw new InputException('Link title cannot be empty.');
+                throw new InputException(__('Link title cannot be empty.'));
             }
 
             $linkData = [
@@ -289,7 +289,7 @@ class LinkRepository implements \Magento\Downloadable\Api\LinkRepositoryInterfac
         /** @var $link \Magento\Downloadable\Model\Link */
         $link = $this->linkFactory->create()->load($linkId);
         if (!$link->getId()) {
-            throw new NoSuchEntityException('There is no downloadable link with provided ID.');
+            throw new NoSuchEntityException(__('There is no downloadable link with provided ID.'));
         }
         $link->delete();
         return true;
diff --git a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php
index d316ef4ccd93bc39d0391847b309974c1c213257..294bd783d463560a5846eada1cc400f5e6a97ce7 100644
--- a/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php
+++ b/app/code/Magento/Downloadable/Model/Sample/ContentValidator.php
@@ -44,7 +44,7 @@ class ContentValidator
     public function isValid(SampleContentInterface $sampleContent)
     {
         if (!is_int($sampleContent->getSortOrder()) || $sampleContent->getSortOrder() < 0) {
-            throw new InputException('Sort order must be a positive integer.');
+            throw new InputException(__('Sort order must be a positive integer.'));
         }
 
         $this->validateSampleResource($sampleContent);
@@ -64,13 +64,13 @@ class ContentValidator
         if ($sampleContent->getSampleType() == 'file'
             && (!$sampleFile || !$this->fileContentValidator->isValid($sampleFile))
         ) {
-            throw new InputException('Provided file content must be valid base64 encoded data.');
+            throw new InputException(__('Provided file content must be valid base64 encoded data.'));
         }
 
         if ($sampleContent->getSampleType() == 'url'
             && !$this->urlValidator->isValid($sampleContent->getSampleUrl())
         ) {
-            throw new InputException('Sample URL must have valid format.');
+            throw new InputException(__('Sample URL must have valid format.'));
         }
     }
 }
diff --git a/app/code/Magento/Downloadable/Model/SampleRepository.php b/app/code/Magento/Downloadable/Model/SampleRepository.php
index d77aaaf1825f8ca3702e29225299067e22897351..b97702bd9adaf8c143dbf0f62823c460121fe02c 100644
--- a/app/code/Magento/Downloadable/Model/SampleRepository.php
+++ b/app/code/Magento/Downloadable/Model/SampleRepository.php
@@ -75,14 +75,14 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte
             $sample = $this->sampleFactory->create()->load($sampleId);
 
             if (!$sample->getId()) {
-                throw new NoSuchEntityException('There is no downloadable sample with provided ID.');
+                throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
             }
 
             if ($sample->getProductId() != $product->getId()) {
-                throw new InputException('Provided downloadable sample is not related to given product.');
+                throw new InputException(__('Provided downloadable sample is not related to given product.'));
             }
             if (!$this->contentValidator->isValid($sampleContent)) {
-                throw new InputException('Provided sample information is invalid.');
+                throw new InputException(__('Provided sample information is invalid.'));
             }
             if ($isGlobalScopeContent) {
                 $product->setStoreId(0);
@@ -91,7 +91,7 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte
             $title = $sampleContent->getTitle();
             if (empty($title)) {
                 if ($isGlobalScopeContent) {
-                    throw new InputException('Sample title cannot be empty.');
+                    throw new InputException(__('Sample title cannot be empty.'));
                 }
                 // use title from GLOBAL scope
                 $sample->setTitle(null);
@@ -108,19 +108,19 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte
         } else {
 
             if ($product->getTypeId() !== \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) {
-                throw new InputException('Product type of the product must be \'downloadable\'.');
+                throw new InputException(__('Product type of the product must be \'downloadable\'.'));
             }
             if (!$this->contentValidator->isValid($sampleContent)) {
-                throw new InputException('Provided sample information is invalid.');
+                throw new InputException(__('Provided sample information is invalid.'));
             }
 
             if (!in_array($sampleContent->getSampleType(), ['url', 'file'])) {
-                throw new InputException('Invalid sample type.');
+                throw new InputException(__('Invalid sample type.'));
             }
 
             $title = $sampleContent->getTitle();
             if (empty($title)) {
-                throw new InputException('Sample title cannot be empty.');
+                throw new InputException(__('Sample title cannot be empty.'));
             }
 
             $sampleData = [
@@ -159,7 +159,7 @@ class SampleRepository implements \Magento\Downloadable\Api\SampleRepositoryInte
         /** @var $sample \Magento\Downloadable\Model\Sample */
         $sample = $this->sampleFactory->create()->load($sampleId);
         if (!$sample->getId()) {
-            throw new NoSuchEntityException('There is no downloadable sample with provided ID.');
+            throw new NoSuchEntityException(__('There is no downloadable sample with provided ID.'));
         }
         $sample->delete();
         return true;
diff --git a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
index 558964315f315229a58605dbc3adf0698fb86629..5b1b7d539d930520b1c118b01f405cc07aa1c171 100644
--- a/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
+++ b/app/code/Magento/Eav/Model/Attribute/GroupRepository.php
@@ -78,14 +78,16 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf
                 throw NoSuchEntityException::singleField('attributeGroupId', $existingGroup->getId());
             }
             if ($existingGroup->getAttributeSetId() != $group->getAttributeSetId()) {
-                throw new StateException('Attribute group does not belong to provided attribute set');
+                throw new StateException(
+                    __('Attribute group does not belong to provided attribute set')
+                );
             }
         }
 
         try {
             $this->groupResource->save($group);
         } catch (\Exception $e) {
-            throw new StateException('Cannot save attributeGroup');
+            throw new StateException(__('Cannot save attributeGroup'));
         }
         return $group;
     }
@@ -125,7 +127,7 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf
         $group = $this->groupFactory->create();
         $this->groupResource->load($group, $groupId);
         if (!$group->getId()) {
-            throw new NoSuchEntityException(sprintf('Group with id "%s" does not exist.', $groupId));
+            throw new NoSuchEntityException(__('Group with id "%1" does not exist.', $groupId));
         }
         return $group;
     }
@@ -139,10 +141,10 @@ class GroupRepository implements \Magento\Eav\Api\AttributeGroupRepositoryInterf
             $this->groupResource->delete($group);
         } catch (\Exception $e) {
             throw new StateException(
-                'Cannot delete attributeGroup with id %attribute_group_id',
-                [
-                    'attribute_group_id' => $group->getId()
-                ],
+                __(
+                    'Cannot delete attributeGroup with id %1',
+                    $group->getId()
+                ),
                 $e
             );
         }
diff --git a/app/code/Magento/Eav/Model/AttributeManagement.php b/app/code/Magento/Eav/Model/AttributeManagement.php
index eb541cb2ebb3bf84d5ccffba84bc2fabf5711718..b687a853039e30474484fd614ead44a2ca69c454 100644
--- a/app/code/Magento/Eav/Model/AttributeManagement.php
+++ b/app/code/Magento/Eav/Model/AttributeManagement.php
@@ -82,19 +82,19 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa
         try {
             $attributeSet = $this->setRepository->get($attributeSetId);
         } catch (NoSuchEntityException $ex) {
-            throw new NoSuchEntityException(sprintf('AttributeSet with id "%s" does not exist.', $attributeSetId));
+            throw new NoSuchEntityException(__('AttributeSet with id "%1" does not exist.', $attributeSetId));
         }
 
         $setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId());
         if ($setEntityType->getEntityTypeCode() != $entityTypeCode) {
-            throw new InputException('Wrong attribute set id provided');
+            throw new InputException(__('Wrong attribute set id provided'));
         }
 
         //Check if group exists. If not - expected exception
         $attributeGroup = $this->groupRepository->get($attributeGroupId);
 
         if ($attributeGroup->getAttributeSetId() != $attributeSetId) {
-            throw new InputException('Attribute group does not belong to attribute set');
+            throw new InputException(__('Attribute group does not belong to attribute set'));
         }
 
         /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
@@ -119,7 +119,7 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa
         try {
             $attributeSet = $this->setRepository->get($attributeSetId);
         } catch (NoSuchEntityException $e) {
-            throw new NoSuchEntityException('Attribute set not found: ' . $attributeSetId);
+            throw new NoSuchEntityException(__('Attribute set not found: %1', $attributeSetId));
         }
         $setEntityType = $this->entityTypeFactory->create()->getEntityType($attributeSet->getEntityTypeId());
 
@@ -132,11 +132,11 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa
 
         if (!$attribute->getEntityAttributeId()) {
             throw new InputException(
-                sprintf('Attribute "%s" not found in attribute set %s.', $attributeCode, $attributeSetId)
+                __('Attribute "%1" not found in attribute set %2.', $attributeCode, $attributeSetId)
             );
         }
         if (!$attribute->getIsUserDefined()) {
-            throw new StateException('System attribute can not be deleted');
+            throw new StateException(__('System attribute can not be deleted'));
         }
         $attribute->deleteEntity();
         return true;
diff --git a/app/code/Magento/Eav/Model/AttributeRepository.php b/app/code/Magento/Eav/Model/AttributeRepository.php
index b3dfb59a88829a072cf65e6dc7fb4c9336459a10..e325fea2f4717844fc93a076076fb13731b3407a 100644
--- a/app/code/Magento/Eav/Model/AttributeRepository.php
+++ b/app/code/Magento/Eav/Model/AttributeRepository.php
@@ -71,7 +71,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa
         try {
             $this->eavResource->save($attribute);
         } catch (\Exception $e) {
-            throw new StateException('Cannot save attribute');
+            throw new StateException(__('Cannot save attribute'));
         }
         return $attribute;
     }
@@ -142,10 +142,9 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa
         /** @var \Magento\Eav\Api\Data\AttributeInterface $attribute */
         $attribute = $this->eavConfig->getAttribute($entityTypeCode, $attributeCode);
         if (!$attribute || !$attribute->getAttributeId()) {
-            throw new NoSuchEntityException(sprintf(
-                'Attribute with attributeCode "%s" does not exist.',
-                $attributeCode
-            ));
+            throw new NoSuchEntityException(
+                __('Attribute with attributeCode "%1" does not exist.', $attributeCode)
+            );
         }
         return $attribute;
     }
@@ -158,7 +157,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa
         try {
             $this->eavResource->delete($attribute);
         } catch (\Exception $e) {
-            throw new StateException('Cannot delete attribute.');
+            throw new StateException(__('Cannot delete attribute.'));
         }
         return true;
     }
@@ -173,7 +172,7 @@ class AttributeRepository implements \Magento\Eav\Api\AttributeRepositoryInterfa
         $this->eavResource->load($attribute, $attributeId);
 
         if (!$attribute->getAttributeId()) {
-            throw new NoSuchEntityException(sprintf('Attribute with id "%s" does not exist.', $attributeId));
+            throw new NoSuchEntityException(__('Attribute with id "%1" does not exist.', $attributeId));
         }
 
         $this->delete($attribute);
diff --git a/app/code/Magento/Eav/Model/AttributeSetManagement.php b/app/code/Magento/Eav/Model/AttributeSetManagement.php
index 729b64b4bb0b81f7f5f81ffd09fb4a47824955b7..4b155096bdb03b862158b1786d31d6ba8ab01f09 100644
--- a/app/code/Magento/Eav/Model/AttributeSetManagement.php
+++ b/app/code/Magento/Eav/Model/AttributeSetManagement.php
@@ -54,7 +54,7 @@ class AttributeSetManagement implements AttributeSetManagementInterface
             $attributeSet->setEntityTypeId($this->eavConfig->getEntityType($entityTypeCode)->getId());
             $attributeSet->validate();
         } catch (\Exception $exception) {
-            throw new InputException($exception->getMessage());
+            throw new InputException(__($exception->getMessage()));
         }
 
         $this->repository->save($attributeSet);
diff --git a/app/code/Magento/Eav/Model/AttributeSetRepository.php b/app/code/Magento/Eav/Model/AttributeSetRepository.php
index dc989a741f09d3dc6a825b156da200cfabf42dea..b54ca8e171e01e394a02fc6ebc380b547dc67700 100644
--- a/app/code/Magento/Eav/Model/AttributeSetRepository.php
+++ b/app/code/Magento/Eav/Model/AttributeSetRepository.php
@@ -75,7 +75,7 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface
         try {
             $this->attributeSetResource->save($attributeSet);
         } catch (\Exception $exception) {
-            throw new CouldNotSaveException('There was an error saving attribute set.');
+            throw new CouldNotSaveException(__('There was an error saving attribute set.'));
         }
         return $attributeSet;
     }
@@ -146,9 +146,9 @@ class AttributeSetRepository implements AttributeSetRepositoryInterface
         try {
             $this->attributeSetResource->delete($attributeSet);
         } catch (\Magento\Framework\Exception\StateException $exception) {
-            throw new CouldNotDeleteException('Default attribute set can not be deleted');
+            throw new CouldNotDeleteException(__('Default attribute set can not be deleted'));
         } catch (\Exception $exception) {
-            throw new CouldNotDeleteException('There was an error deleting attribute set.');
+            throw new CouldNotDeleteException(__('There was an error deleting attribute set.'));
         }
         return true;
     }
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
index a9deaed6b17eb98f6ebf630df6c5c66ee755c946..188f9818c2da25400fb65320fdc5c3fe30ea94f2 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php
@@ -40,12 +40,12 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte
     public function add($entityType, $attributeCode, $option)
     {
         if (empty($attributeCode)) {
-            throw new InputException('Empty attribute code');
+            throw new InputException(__('Empty attribute code'));
         }
 
         $attribute = $this->attributeRepository->get($entityType, $attributeCode);
         if (!$attribute->usesSource()) {
-            throw new StateException(sprintf('Attribute %s doesn\'t work with options', $attributeCode));
+            throw new StateException(__('Attribute %1 doesn\'t work with options', $attributeCode));
         }
         $key = 'new_option';
 
@@ -67,7 +67,7 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte
         try {
             $this->resourceModel->save($attribute);
         } catch (\Exception $e) {
-            throw new StateException(sprintf('Cannot save attribute %s', $attributeCode));
+            throw new StateException(__('Cannot save attribute %1', $attributeCode));
         }
 
         return true;
@@ -79,17 +79,17 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte
     public function delete($entityType, $attributeCode, $optionId)
     {
         if (empty($attributeCode)) {
-            throw new InputException('Empty attribute code');
+            throw new InputException(__('Empty attribute code'));
         }
 
         $attribute = $this->attributeRepository->get($entityType, $attributeCode);
         if (!$attribute->usesSource()) {
-            throw new StateException(sprintf('Attribute %s doesn\'t have any option', $attributeCode));
+            throw new StateException(__('Attribute %1 doesn\'t have any option', $attributeCode));
         }
 
         if (!$attribute->getSource()->getOptionText($optionId)) {
             throw new NoSuchEntityException(
-                sprintf('Attribute %s does not contain option with Id %s', $attribute->getId(), $optionId)
+                __('Attribute %1 does not contain option with Id %2', $attribute->getId(), $optionId)
             );
         }
 
@@ -103,7 +103,7 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte
         try {
             $this->resourceModel->save($attribute);
         } catch (\Exception $e) {
-            throw new StateException(sprintf('Cannot save attribute %s', $attributeCode));
+            throw new StateException(__('Cannot save attribute %1', $attributeCode));
         }
 
         return true;
@@ -115,14 +115,14 @@ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInte
     public function getItems($entityType, $attributeCode)
     {
         if (empty($attributeCode)) {
-            throw new InputException('Empty attribute code');
+            throw new InputException(__('Empty attribute code'));
         }
         $attribute = $this->attributeRepository->get($entityType, $attributeCode);
 
         try {
             $options = $attribute->getOptions();
         } catch (\Exception $e) {
-            throw new StateException(sprintf('Cannot load options for attribute %s', $attributeCode));
+            throw new StateException(__('Cannot load options for attribute %1', $attributeCode));
         }
 
         return $options;
diff --git a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
index 0c083a7d88c9ca12325e9bca91d3ab870debac6f..a8be4ca3978edb155c11000b5fea88bee281f744 100644
--- a/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
+++ b/app/code/Magento/Eav/Model/Resource/Entity/Attribute/Set.php
@@ -104,7 +104,9 @@ class Set extends \Magento\Framework\Model\Resource\Db\AbstractDb
             ->getEntityType($object->getEntityTypeId())
             ->getDefaultAttributeSetId();
         if ($object->getAttributeSetId() == $defaultAttributeSetId) {
-            throw new \Magento\Framework\Exception\StateException('Default attribute set can not be deleted');
+            throw new \Magento\Framework\Exception\StateException(
+                __('Default attribute set can not be deleted')
+            );
         }
         return parent::_beforeDelete($object);
     }
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
index 377aa2277184687d8ad6f6c20ef2d9166c0466c2..41dc92df72f0fdcc2c8b21dd868934e55d3427c5 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Attribute/GroupRepositoryTest.php
@@ -37,6 +37,11 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
      */
     protected $groupListFactoryMock;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     protected function setUp()
     {
         $this->groupResourceMock = $this->getMock(
@@ -82,6 +87,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test saving if object is new
+     *
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
+     */
     public function testSaveIfObjectNew()
     {
         $attributeSetId = 42;
@@ -100,6 +112,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($groupMock, $this->model->save($groupMock));
     }
 
+    /**
+     * Test saving if object is not new
+     *
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
+     */
     public function testSaveIfObjectNotNew()
     {
         $attributeSetId = 42;
@@ -127,8 +146,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test saving throws exception if attribute set does not exist
+     *
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage No such entity with attributeSetId = -1
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
      */
     public function testSaveThrowExceptionIfAttributeSetDoesNotExist()
     {
@@ -140,15 +164,20 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
             ->with($attributeSetId)
             ->will(
                 $this->throwException(
-                    new \Magento\Framework\Exception\NoSuchEntityException('AttributeSet does not exist.')
+                    new \Magento\Framework\Exception\NoSuchEntityException(__('AttributeSet does not exist.'))
                 )
             );
         $this->model->save($groupMock);
     }
 
     /**
+     * Test saving throws exception if cannot save group
+     *
      * @expectedException \Magento\Framework\Exception\StateException
      * @expectedExceptionMessage Cannot save attributeGroup
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
      */
     public function testSaveThrowExceptionIfCannotSaveGroup()
     {
@@ -170,8 +199,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test saving throws exception if group does not belong to provided set
+     *
      * @expectedException \Magento\Framework\Exception\StateException
      * @expectedExceptionMessage Attribute group does not belong to provided attribute set
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
      */
     public function testSaveThrowExceptionIfGroupDoesNotBelongToProvidedSet()
     {
@@ -192,8 +226,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test saving throws exception if provided group does not exist
+     *
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage No such entity with attributeGroupId =
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
      */
     public function testSaveThrowExceptionIfProvidedGroupDoesNotExist()
     {
@@ -213,6 +252,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->save($groupMock);
     }
 
+    /**
+     * Test get list
+     *
+     * @throws \Magento\Framework\Exception\InputException
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @return void
+     */
     public function testGetList()
     {
         $attributeSetId = 'filter';
@@ -261,8 +307,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test get list with invalid input exception
+     *
      * @expectedException \Magento\Framework\Exception\InputException
      * @expectedExceptionMessage attribute_set_id is a required field.
+     * @throws \Magento\Framework\Exception\InputException
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @return void
      */
     public function testGetListWithInvalidInputException()
     {
@@ -272,8 +323,13 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test get list with no such entity exception
+     *
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage No such entity with attributeSetId = filter
+     * @throws \Magento\Framework\Exception\InputException
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @return void
      */
     public function testGetListWithNoSuchEntityException()
     {
@@ -296,6 +352,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->getList($searchCriteriaMock);
     }
 
+    /**
+     * Test get
+     *
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @return void
+     */
     public function testGet()
     {
         $groupId = 42;
@@ -307,8 +369,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test get throws exception if provided group does not exist
+     *
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage Group with id "42" does not exist.
+     * @throws \Magento\Framework\Exception\NoSuchEntityException
+     * @return void
      */
     public function testGetThrowExceptionIfProvidedGroupDoesNotExist()
     {
@@ -320,6 +386,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($groupMock, $this->model->get($groupId));
     }
 
+    /**
+     * Test delete
+     *
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
+     */
     public function testDelete()
     {
         $groupMock = $this->getMock('\Magento\Eav\Model\Entity\Attribute\Group', [], [], '', false);
@@ -328,8 +400,12 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test deletion throws exception if provided group does not exist
+     *
      * @expectedException \Magento\Framework\Exception\StateException
      * @expectedExceptionMessage Cannot delete attributeGroup with id
+     * @throws \Magento\Framework\Exception\StateException
+     * @return void
      */
     public function testDeleteThrowExceptionIfProvidedGroupDoesNotExist()
     {
@@ -342,6 +418,11 @@ class GroupRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->delete($groupMock);
     }
 
+    /**
+     * Test delete by id
+     *
+     * @return void
+     */
     public function testDeleteById()
     {
         $groupId = 42;
diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
index 7f78d74400132cffe78494e01573be27706a5dd2..8d2dd6fcbcbea2ec94b68cf3a141e20fea1c13d3 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php
@@ -312,7 +312,7 @@ class AttributeManagementTest extends \PHPUnit_Framework_TestCase
         $this->setRepositoryMock->expects($this->once())
             ->method('get')
             ->with($attributeSetId)
-            ->willThrowException(new NoSuchEntityException('hello'));
+            ->willThrowException(new NoSuchEntityException(__('hello')));
 
         $this->model->unassign($attributeSetId, $attributeCode);
     }
diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
index 2b710da0cfab25d5cda2f9c97db05aeff4b91124..5975bf3b5f422e39a24faf4c58e8c4d3354bc50b 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeSetRepositoryTest.php
@@ -42,6 +42,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
      */
     private $resultFactoryMock;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->resourceMock = $this->getMock(
@@ -82,6 +85,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testGet()
     {
         $attributeSetId = 1;
@@ -93,6 +99,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage No such entity with id = 9999
      */
@@ -105,6 +112,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->get($attributeSetId);
     }
 
+    /**
+     * @return void
+     */
     public function testSave()
     {
         $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false);
@@ -113,6 +123,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotSaveException
      * @expectedExceptionMessage There was an error saving attribute set.
      */
@@ -125,6 +136,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->save($attributeSetMock);
     }
 
+    /**
+     * @return void
+     */
     public function testDelete()
     {
         $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false);
@@ -133,6 +147,7 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
      * @expectedExceptionMessage There was an error deleting attribute set.
      */
@@ -140,12 +155,13 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
     {
         $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false);
         $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException(
-            new \Magento\Framework\Exception\CouldNotDeleteException('Some internal exception message.')
+            new \Magento\Framework\Exception\CouldNotDeleteException(__('Some internal exception message.'))
         );
         $this->model->delete($attributeSetMock);
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
      * @expectedExceptionMessage Default attribute set can not be deleted
      */
@@ -153,11 +169,14 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
     {
         $attributeSetMock = $this->getMock('Magento\Eav\Model\Entity\Attribute\Set', [], [], '', false);
         $this->resourceMock->expects($this->once())->method('delete')->with($attributeSetMock)->willThrowException(
-            new \Magento\Framework\Exception\StateException('Some internal exception message.')
+            new \Magento\Framework\Exception\StateException(__('Some internal exception message.'))
         );
         $this->model->delete($attributeSetMock);
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteById()
     {
         $attributeSetId = 1;
@@ -169,6 +188,9 @@ class AttributeSetRepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->model->deleteById($attributeSetId));
     }
 
+    /**
+     * @return void
+     */
     public function testGetList()
     {
         $entityTypeCode = 'entity_type_code_value';
diff --git a/app/code/Magento/GiftMessage/Model/CartRepository.php b/app/code/Magento/GiftMessage/Model/CartRepository.php
index 528ccf78320b624bdbdcf75bbf5aac889108dbc9..bb1b66db7d20d0f5b42e2321eaf354030e4661f9 100644
--- a/app/code/Magento/GiftMessage/Model/CartRepository.php
+++ b/app/code/Magento/GiftMessage/Model/CartRepository.php
@@ -101,14 +101,14 @@ class CartRepository implements \Magento\GiftMessage\Api\CartRepositoryInterface
         $quote = $this->quoteRepository->getActive($cartId);
 
         if (0 == $quote->getItemsCount()) {
-            throw new InputException('Gift Messages is not applicable for empty cart');
+            throw new InputException(__('Gift Messages is not applicable for empty cart'));
         }
 
         if ($quote->isVirtual()) {
-            throw new InvalidTransitionException('Gift Messages is not applicable for virtual products');
+            throw new InvalidTransitionException(__('Gift Messages is not applicable for virtual products'));
         }
         if (!$this->helper->getIsMessagesAvailable('quote', $quote, $this->storeManager->getStore())) {
-            throw new CouldNotSaveException('Gift Message is not available');
+            throw new CouldNotSaveException(__('Gift Message is not available'));
         }
         $this->giftMessageManager->setMessage($quote, 'quote', $giftMessage);
         return true;
diff --git a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
index 55c2b0020c15cea8c26846897e7357693f03e515..f1d2cfbfb95170505c32cbe150907db060de5e8e 100644
--- a/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
+++ b/app/code/Magento/GiftMessage/Model/GiftMessageManager.php
@@ -105,12 +105,12 @@ class GiftMessageManager
     public function setMessage(\Magento\Quote\Model\Quote $quote, $type, $giftMessage, $entityId = null)
     {
         if (is_null($quote->getBillingAddress()->getCountryId())) {
-            throw new InvalidTransitionException('Billing address is not set');
+            throw new InvalidTransitionException(__('Billing address is not set'));
         }
 
         // check if shipping address is set
         if (is_null($quote->getShippingAddress()->getCountryId())) {
-            throw new InvalidTransitionException('Shipping address is not set');
+            throw new InvalidTransitionException(__('Shipping address is not set'));
         }
         $message[$type][$entityId] = [
             'from' => $giftMessage->getSender(),
@@ -121,7 +121,7 @@ class GiftMessageManager
         try {
             $this->add($message, $quote);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not add gift message to shopping cart');
+            throw new CouldNotSaveException(__('Could not add gift message to shopping cart'));
         }
     }
 }
diff --git a/app/code/Magento/GiftMessage/Model/ItemRepository.php b/app/code/Magento/GiftMessage/Model/ItemRepository.php
index 90db371ca8fbdf8ffad383f375a9350e81fdbd01..16d442a769240fef8fb93ced6c29ea8fc479d022 100644
--- a/app/code/Magento/GiftMessage/Model/ItemRepository.php
+++ b/app/code/Magento/GiftMessage/Model/ItemRepository.php
@@ -85,7 +85,7 @@ class ItemRepository implements \Magento\GiftMessage\Api\ItemRepositoryInterface
          */
         $quote = $this->quoteRepository->getActive($cartId);
         if (!$item = $quote->getItemById($itemId)) {
-            throw new NoSuchEntityException('There is no item with provided id in the cart');
+            throw new NoSuchEntityException(__('There is no item with provided id in the cart'));
         };
         $messageId = $item->getGiftMessageId();
         if (!$messageId) {
@@ -113,14 +113,16 @@ class ItemRepository implements \Magento\GiftMessage\Api\ItemRepositoryInterface
         $quote = $this->quoteRepository->getActive($cartId);
 
         if (!$item = $quote->getItemById($itemId)) {
-            throw new NoSuchEntityException("There is no product with provided  itemId: $itemId in the cart");
+            throw new NoSuchEntityException(
+                __('There is no product with provided  itemId: %1 in the cart', $itemId)
+            );
         };
 
         if ($item->getIsVirtual()) {
-            throw new InvalidTransitionException('Gift Messages is not applicable for virtual products');
+            throw new InvalidTransitionException(__('Gift Messages is not applicable for virtual products'));
         }
         if (!$this->helper->getIsMessagesAvailable('items', $quote, $this->storeManager->getStore())) {
-            throw new CouldNotSaveException('Gift Message is not available');
+            throw new CouldNotSaveException(__('Gift Message is not available'));
         }
         $this->giftMessageManager->setMessage($quote, 'quote_item', $giftMessage, $itemId);
         return true;
diff --git a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
index 3bef3409371aa89dbae008a25c17dd2fe54aae98..2703f0b1087d41cbba7516091f98ccb91ed795f4 100644
--- a/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
+++ b/app/code/Magento/GoogleShopping/Model/Attribute/Tax.php
@@ -164,7 +164,7 @@ class Tax extends \Magento\GoogleShopping\Model\Attribute\DefaultAttribute
                 $ratesTotal += count($regions);
                 if ($ratesTotal > self::RATES_MAX) {
                     throw new \Magento\Framework\Exception\LocalizedException(
-                        __("Google shopping only supports %1 tax rates per product", self::RATES_MAX)
+                        __('Google shopping only supports %1 tax rates per product', self::RATES_MAX)
                     );
                 }
                 foreach ($regions as $region) {
diff --git a/app/code/Magento/GoogleShopping/Model/Service.php b/app/code/Magento/GoogleShopping/Model/Service.php
index 7481a8007e6db19343202cb558001129d9a07232..63a8ef94917b91e63867f21b7d7e4543c399ac93 100644
--- a/app/code/Magento/GoogleShopping/Model/Service.php
+++ b/app/code/Magento/GoogleShopping/Model/Service.php
@@ -90,9 +90,8 @@ class Service extends \Magento\Framework\Object
         $type = $this->getConfig()->getAccountType($storeId);
 
         // Create an authenticated HTTP client
-        $errorMsg = __(
-            'Sorry, but we can\'t connect to Google Content. Please check the account settings in your store configuration.'
-        );
+        $errorMsg = 'Sorry, but we can\'t connect to Google Content.'
+            . 'Please check the account settings in your store configuration.';
         try {
             if (!$this->_coreRegistry->registry($this->_clientRegistryId)) {
                 $client = \Zend_Gdata_ClientLogin::getHttpClient(
@@ -113,9 +112,9 @@ class Service extends \Magento\Framework\Object
         } catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
             throw $e;
         } catch (\Zend_Gdata_App_HttpException $e) {
-            throw new \Magento\Framework\Exception\LocalizedException($errorMsg . __('Error: %1', $e->getMessage()));
+            throw new \Magento\Framework\Exception\LocalizedException(__('%1 Error: %2', $errorMsg, $e->getMessage()));
         } catch (\Zend_Gdata_App_AuthException $e) {
-            throw new \Magento\Framework\Exception\LocalizedException($errorMsg . __('Error: %1', $e->getMessage()));
+            throw new \Magento\Framework\Exception\LocalizedException(__('%1 Error: %2', $errorMsg, $e->getMessage()));
         }
 
         return $this->_coreRegistry->registry($this->_clientRegistryId);
diff --git a/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php b/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php
index bb417b4f0fe478e97833f6650bcf854b3bd4e0d8..fa6854a990f3b44eec48499b1285c6cb9debe660 100644
--- a/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php
+++ b/app/code/Magento/GoogleShopping/Test/Unit/Model/MassOperationsTest.php
@@ -43,6 +43,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
     /** @var \Magento\GoogleShopping\Model\Flag|\PHPUnit_Framework_MockObject_MockObject */
     protected $flag;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->collectionFactory = $this->getMockBuilder(
@@ -80,6 +83,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testAddProducts()
     {
         $products = ['1','2'];
@@ -93,6 +99,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->massOperations->addProducts($products, 1), $this->massOperations);
     }
 
+    /**
+     * @return void
+     */
     public function testAddProductsExpiredFlag()
     {
         $products = ['1','2'];
@@ -102,8 +111,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @dataProvider dataAddProductsExceptions
      * @param string $exception
+     * @return void
+     * @dataProvider dataAddProductsExceptions
      */
     public function testAddProductsExceptions($exception)
     {
@@ -113,7 +123,7 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         $this->productRepository->expects($this->once())->method('getById')->will($this->returnValue($product));
         $this->itemFactory->expects($this->once())
             ->method('create')
-            ->willThrowException(new $exception('message'));
+            ->willThrowException(new $exception(__('message')));
         $this->massOperations->setFlag($this->flag);
         $this->massOperations->addProducts($products, 1);
     }
@@ -132,6 +142,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         ];
     }
 
+    /**
+     * @return void
+     */
     public function testSynchronizeItems()
     {
         $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection')
@@ -154,6 +167,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         $this->massOperations->synchronizeItems([1]);
     }
 
+    /**
+     * @return void
+     */
     public function testSynchronizeItemsWithException()
     {
         $collection = $this->getMockBuilder('Magento\GoogleShopping\Model\Resource\Item\Collection')
@@ -182,6 +198,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         $this->massOperations->synchronizeItems([1]);
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteItems()
     {
         $item = $this->getMockBuilder('Magento\GoogleShopping\Model\Item')->disableOriginalConstructor()->getMock();
@@ -206,6 +225,9 @@ class MassOperationsTest extends \PHPUnit_Framework_TestCase
         $this->massOperations->deleteItems([1]);
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteItemsWitException()
     {
         $product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor()
diff --git a/app/code/Magento/ImportExport/Helper/Data.php b/app/code/Magento/ImportExport/Helper/Data.php
index 2694d4a0201dfa5a6b119544adf0ae7438d2aa00..462fd7f424b3e4d76d838191ed09efb7700227e0 100644
--- a/app/code/Magento/ImportExport/Helper/Data.php
+++ b/app/code/Magento/ImportExport/Helper/Data.php
@@ -46,7 +46,7 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
     /**
      * Get maximum upload size message
      *
-     * @return string
+     * @return \Magento\Framework\Phrase
      */
     public function getMaxUploadSizeMessage()
     {
diff --git a/app/code/Magento/ImportExport/Model/Export.php b/app/code/Magento/ImportExport/Model/Export.php
index c3030a1cff44b313eceeebc5ea572bb0323f7fa7..227fd2fab3c54d489adb565b8fd1187a01fee832 100644
--- a/app/code/Magento/ImportExport/Model/Export.php
+++ b/app/code/Magento/ImportExport/Model/Export.php
@@ -97,7 +97,9 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
                     $this->_entityAdapter = $this->_entityFactory->create($entities[$this->getEntity()]['model']);
                 } catch (\Exception $e) {
                     $this->_logger->critical($e);
-                    throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model'));
+                    throw new \Magento\Framework\Exception\LocalizedException(
+                        __('Please enter a correct entity model')
+                    );
                 }
                 if (!$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\Entity\AbstractEntity &&
                     !$this->_entityAdapter instanceof \Magento\ImportExport\Model\Export\AbstractEntity
@@ -141,7 +143,9 @@ class Export extends \Magento\ImportExport\Model\AbstractModel
                     $this->_writer = $this->_exportAdapterFac->create($fileFormats[$this->getFileFormat()]['model']);
                 } catch (\Exception $e) {
                     $this->_logger->critical($e);
-                    throw new \Magento\Framework\Exception\LocalizedException(__('Please enter a correct entity model'));
+                    throw new \Magento\Framework\Exception\LocalizedException(
+                        __('Please enter a correct entity model')
+                    );
                 }
                 if (!$this->_writer instanceof \Magento\ImportExport\Model\Export\Adapter\AbstractAdapter) {
                     throw new \Magento\Framework\Exception\LocalizedException(
diff --git a/app/code/Magento/ImportExport/Model/Import.php b/app/code/Magento/ImportExport/Model/Import.php
index 678d2889b01f0dd0a14fe0dc74e6c97d2b7f17a8..c09a012798e1d6f3fc9075440cedf77aa8277c38 100644
--- a/app/code/Magento/ImportExport/Model/Import.php
+++ b/app/code/Magento/ImportExport/Model/Import.php
@@ -504,7 +504,7 @@ class Import extends \Magento\ImportExport\Model\AbstractModel
             $this->_getSourceAdapter($sourceFile);
         } catch (\Exception $e) {
             $this->_varDirectory->delete($sourceFileRelative);
-            throw new \Magento\Framework\Exception\LocalizedException($e->getMessage());
+            throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
         }
         return $sourceFile;
     }
diff --git a/app/code/Magento/Integration/Model/CredentialsValidator.php b/app/code/Magento/Integration/Model/CredentialsValidator.php
index 2e86222cb702c783adbcc74d28b3851c111ff237..18a8938658951fb3c6cdfa8b7521c18646b60d66 100644
--- a/app/code/Magento/Integration/Model/CredentialsValidator.php
+++ b/app/code/Magento/Integration/Model/CredentialsValidator.php
@@ -25,10 +25,10 @@ class CredentialsValidator
     {
         $exception = new InputException();
         if (!is_string($username) || strlen($username) == 0) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'username']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'username']));
         }
         if (!is_string($username) || strlen($password) == 0) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'password']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'password']));
         }
         if ($exception->wasErrorAdded()) {
             throw $exception;
diff --git a/app/code/Magento/Integration/Model/Oauth/Consumer.php b/app/code/Magento/Integration/Model/Oauth/Consumer.php
index faf3531395b57e596a19567322b7f2547d34b7af..7a40e1b5b693290f2efe84935a9a01f002be0daf 100644
--- a/app/code/Magento/Integration/Model/Oauth/Consumer.php
+++ b/app/code/Magento/Integration/Model/Oauth/Consumer.php
@@ -120,14 +120,14 @@ class Consumer extends \Magento\Framework\Model\AbstractModel implements Consume
         $validatorLength->setName('Consumer Key');
         if (!$validatorLength->isValid($this->getKey())) {
             $messages = $validatorLength->getMessages();
-            throw new \Magento\Framework\Exception\LocalizedException(array_shift($messages));
+            throw new \Magento\Framework\Exception\LocalizedException(__(array_shift($messages)));
         }
 
         $validatorLength->setLength(\Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_SECRET);
         $validatorLength->setName('Consumer Secret');
         if (!$validatorLength->isValid($this->getSecret())) {
             $messages = $validatorLength->getMessages();
-            throw new \Magento\Framework\Exception\LocalizedException(array_shift($messages));
+            throw new \Magento\Framework\Exception\LocalizedException(__(array_shift($messages)));
         }
         return true;
     }
diff --git a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php
index 697561a24cc61d76c807834ff30cd4153b950295..a10cdcb07d37a9a2d16616d67e615937568939e6 100644
--- a/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php
+++ b/app/code/Magento/Integration/Model/Oauth/Nonce/Generator.php
@@ -78,7 +78,7 @@ class Generator implements NonceGeneratorInterface
             $timestamp = (int)$timestamp;
             if ($timestamp <= 0 || $timestamp > time() + self::TIME_DEVIATION) {
                 throw new \Magento\Framework\Oauth\OauthInputException(
-                    'Incorrect timestamp value in the oauth_timestamp parameter'
+                    __('Incorrect timestamp value in the oauth_timestamp parameter')
                 );
             }
 
@@ -87,8 +87,10 @@ class Generator implements NonceGeneratorInterface
 
             if ($nonceObj->getNonce()) {
                 throw new \Magento\Framework\Oauth\Exception(
-                    'The nonce is already being used by the consumer with ID %1',
-                    [$consumer->getId()]
+                    __(
+                        'The nonce is already being used by the consumer with ID %1',
+                        [$consumer->getId()]
+                    )
                 );
             }
 
@@ -96,7 +98,7 @@ class Generator implements NonceGeneratorInterface
         } catch (\Magento\Framework\Oauth\Exception $exception) {
             throw $exception;
         } catch (\Exception $exception) {
-            throw new \Magento\Framework\Oauth\Exception('An error occurred validating the nonce');
+            throw new \Magento\Framework\Oauth\Exception(__('An error occurred validating the nonce'));
         }
     }
 }
diff --git a/app/code/Magento/Integration/Model/Oauth/Token.php b/app/code/Magento/Integration/Model/Oauth/Token.php
index 7757ed194ffd3e2a249cc5c83f67a97887e59613..88f2efb713cff4cbf69bdf568d608d32951a63f0 100644
--- a/app/code/Magento/Integration/Model/Oauth/Token.php
+++ b/app/code/Magento/Integration/Model/Oauth/Token.php
@@ -186,7 +186,7 @@ class Token extends \Magento\Framework\Model\AbstractModel
     public function convertToAccess()
     {
         if (self::TYPE_REQUEST != $this->getType()) {
-            throw new OauthException('Cannot convert to access token due to token is not request type');
+            throw new OauthException(__('Cannot convert to access token due to token is not request type'));
         }
         return $this->saveAccessToken(UserContextInterface::USER_TYPE_INTEGRATION);
     }
@@ -278,7 +278,7 @@ class Token extends \Magento\Framework\Model\AbstractModel
         )
         ) {
             $messages = $this->_urlValidator->getMessages();
-            throw new OauthException(array_shift($messages));
+            throw new OauthException(__(array_shift($messages)));
         }
 
         /** @var $validatorLength \Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength */
@@ -287,14 +287,14 @@ class Token extends \Magento\Framework\Model\AbstractModel
         $validatorLength->setName('Token Secret Key');
         if (!$validatorLength->isValid($this->getSecret())) {
             $messages = $validatorLength->getMessages();
-            throw new OauthException(array_shift($messages));
+            throw new OauthException(__(array_shift($messages)));
         }
 
         $validatorLength->setLength(OauthHelper::LENGTH_TOKEN);
         $validatorLength->setName('Token Key');
         if (!$validatorLength->isValid($this->getToken())) {
             $messages = $validatorLength->getMessages();
-            throw new OauthException(array_shift($messages));
+            throw new OauthException(__(array_shift($messages)));
         }
 
         if (null !== ($verifier = $this->getVerifier())) {
@@ -302,7 +302,7 @@ class Token extends \Magento\Framework\Model\AbstractModel
             $validatorLength->setName('Verifier Key');
             if (!$validatorLength->isValid($verifier)) {
                 $messages = $validatorLength->getMessages();
-                throw new OauthException(array_shift($messages));
+                throw new OauthException(__(array_shift($messages)));
             }
         }
         return true;
diff --git a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php
index 8d12af0f3c4ad25747db41ff423502265a606678..550d895dac700073cab0807f4cee245eea758cc2 100644
--- a/app/code/Magento/Integration/Model/Oauth/Token/Provider.php
+++ b/app/code/Magento/Integration/Model/Oauth/Token/Provider.php
@@ -50,7 +50,7 @@ class Provider implements TokenProviderInterface
         // Must use consumer within expiration period.
         if (!$consumer->isValidForTokenExchange()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Consumer key has expired'
+                __('Consumer key has expired')
             );
         }
         return true;
@@ -64,7 +64,7 @@ class Provider implements TokenProviderInterface
         $token = $this->getIntegrationTokenByConsumerId($consumer->getId());
         if ($token->getType() != Token::TYPE_VERIFIER) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Cannot create request token because consumer token is not a verifier token'
+                __('Cannot create request token because consumer token is not a verifier token')
             );
         }
         $requestToken = $token->createRequestToken($token->getId(), $consumer->getCallbackUrl());
@@ -80,7 +80,7 @@ class Provider implements TokenProviderInterface
 
         if (!$this->_isTokenAssociatedToConsumer($token, $consumer)) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Request token is not associated with the specified consumer'
+                __('Request token is not associated with the specified consumer')
             );
         }
 
@@ -88,7 +88,7 @@ class Provider implements TokenProviderInterface
         // In this flow (token flow) the token has to be of type "request" else its marked as reused.
         if (Token::TYPE_REQUEST != $token->getType()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token is already being used'
+                __('Token is already being used')
             );
         }
 
@@ -106,7 +106,7 @@ class Provider implements TokenProviderInterface
         $token = $this->getIntegrationTokenByConsumerId($consumerId);
         if (Token::TYPE_REQUEST != $token->getType()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Cannot get access token because consumer token is not a request token'
+                __('Cannot get access token because consumer token is not a request token')
             );
         }
         $accessToken = $token->convertToAccess();
@@ -125,17 +125,17 @@ class Provider implements TokenProviderInterface
 
         if (!$this->_isTokenAssociatedToConsumer($token, $consumer)) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token is not associated with the specified consumer'
+                __('Token is not associated with the specified consumer')
             );
         }
         if (Token::TYPE_ACCESS != $token->getType()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token is not an access token'
+                __('Token is not an access token')
             );
         }
         if ($token->getRevoked()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Access token has been revoked'
+                __('Access token has been revoked')
             );
         }
 
@@ -153,13 +153,13 @@ class Provider implements TokenProviderInterface
 
         if (Token::TYPE_ACCESS != $token->getType()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token is not an access token'
+                __('Token is not an access token')
             );
         }
 
         if ($token->getRevoked()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Access token has been revoked'
+                __('Access token has been revoked')
             );
         }
 
@@ -181,7 +181,7 @@ class Provider implements TokenProviderInterface
     {
         if (strlen($consumerKey) != \Magento\Framework\Oauth\Helper\Oauth::LENGTH_CONSUMER_KEY) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Consumer key is not the correct length'
+                __('Consumer key is not the correct length')
             );
         }
 
@@ -189,7 +189,7 @@ class Provider implements TokenProviderInterface
 
         if (!$consumer->getId()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'A consumer having the specified key does not exist'
+                __('A consumer having the specified key does not exist')
             );
         }
 
@@ -208,17 +208,17 @@ class Provider implements TokenProviderInterface
     {
         if (!is_string($oauthVerifier)) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Verifier is invalid'
+                __('Verifier is invalid')
             );
         }
         if (!$this->validateOauthToken($oauthVerifier)) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Verifier is not the correct length'
+                __('Verifier is not the correct length')
             );
         }
         if ($tokenVerifier != $oauthVerifier) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token verifier and verifier token do not match'
+                __('Token verifier and verifier token do not match')
             );
         }
     }
@@ -236,8 +236,10 @@ class Provider implements TokenProviderInterface
 
         if (!$consumer->getId()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'A consumer with the ID %1 does not exist',
-                [$consumerId]
+                __(
+                    'A consumer with the ID %1 does not exist',
+                    [$consumerId]
+                )
             );
         }
 
@@ -255,7 +257,7 @@ class Provider implements TokenProviderInterface
     {
         if (!$this->validateOauthToken($token)) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Token is not the correct length'
+                __('Token is not the correct length')
             );
         }
 
@@ -263,7 +265,7 @@ class Provider implements TokenProviderInterface
 
         if (!$tokenObj->getId()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Specified token does not exist'
+                __('Specified token does not exist')
             );
         }
 
@@ -285,8 +287,10 @@ class Provider implements TokenProviderInterface
 
         if (!$token->getId()) {
             throw new \Magento\Framework\Oauth\Exception(
-                'A token with consumer ID %1 does not exist',
-                [$consumerId]
+                __(
+                    'A token with consumer ID %1 does not exist',
+                    [$consumerId]
+                )
             );
         }
 
diff --git a/app/code/Magento/Integration/Service/V1/AdminTokenService.php b/app/code/Magento/Integration/Service/V1/AdminTokenService.php
index 12beccdb3bb4e04ee3c1851a4909f5b5c5445d0b..7fb947eacd8204163b825656ec3b702c85cef445 100644
--- a/app/code/Magento/Integration/Service/V1/AdminTokenService.php
+++ b/app/code/Magento/Integration/Service/V1/AdminTokenService.php
@@ -72,20 +72,14 @@ class AdminTokenService implements AdminTokenServiceInterface
     public function createAdminAccessToken($username, $password)
     {
         $this->validatorHelper->validate($username, $password);
-        try {
-            $this->userModel->login($username, $password);
-            if (!$this->userModel->getId()) {
-                /*
-                 * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent.
-                 * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it.
-                 * Need to make sure that this is refactored once exception handling is updated in Auth Model.
-                 */
-                throw new AuthenticationException('Please correct the user name or password.');
-            }
-        } catch (\Magento\Framework\Exception\AuthenticationException $e) {
-            throw new AuthenticationException($e->getMessage(), [], $e);
-        } catch (\Magento\Framework\Exception\LocalizedException $e) {
-            throw new LocalizedException($e->getMessage(), [], $e);
+        $this->userModel->login($username, $password);
+        if (!$this->userModel->getId()) {
+            /*
+             * This message is same as one thrown in \Magento\Backend\Model\Auth to keep the behavior consistent.
+             * Constant cannot be created in Auth Model since it uses legacy translation that doesn't support it.
+             * Need to make sure that this is refactored once exception handling is updated in Auth Model.
+             */
+            throw new AuthenticationException(__('Please correct the user name or password.'));
         }
         return $this->tokenModelFactory->create()->createAdminToken($this->userModel->getId())->getToken();
     }
diff --git a/app/code/Magento/Integration/Service/V1/Oauth.php b/app/code/Magento/Integration/Service/V1/Oauth.php
index ff45e641fa1e5bc11d910f031ae7750934c21aa7..9f59d33da5b6826b032d8948b180a55bcb5b6a33 100644
--- a/app/code/Magento/Integration/Service/V1/Oauth.php
+++ b/app/code/Magento/Integration/Service/V1/Oauth.php
@@ -108,7 +108,7 @@ class Oauth implements OauthInterface
             throw $exception;
         } catch (\Exception $exception) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Unexpected error. Unable to create oAuth consumer account.'
+                __('Unexpected error. Unable to create oAuth consumer account.')
             );
         }
     }
@@ -165,7 +165,7 @@ class Oauth implements OauthInterface
             throw $exception;
         } catch (\Exception $exception) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Unexpected error. Unable to load oAuth consumer account.'
+                __('Unexpected error. Unable to load oAuth consumer account.')
             );
         }
     }
@@ -181,7 +181,7 @@ class Oauth implements OauthInterface
             throw $exception;
         } catch (\Exception $exception) {
             throw new \Magento\Framework\Oauth\Exception(
-                'Unexpected error. Unable to load oAuth consumer account.'
+                __('Unexpected error. Unable to load oAuth consumer account.')
             );
         }
     }
@@ -195,8 +195,7 @@ class Oauth implements OauthInterface
             $consumer = $this->_consumerFactory->create()->load($consumerId);
             if (!$consumer->getId()) {
                 throw new \Magento\Framework\Oauth\Exception(
-                    __('A consumer with ID %1 does not exist', $consumerId),
-                    OauthInterface::ERR_PARAMETER_REJECTED
+                    __('A consumer with ID %1 does not exist', $consumerId)
                 );
             }
             $consumerData = $consumer->getData();
@@ -223,7 +222,7 @@ class Oauth implements OauthInterface
         } catch (\Exception $exception) {
             $this->_logger->critical($exception);
             throw new \Magento\Framework\Oauth\Exception(
-                'Unable to post data to consumer due to an unexpected error'
+                __('Unable to post data to consumer due to an unexpected error')
             );
         }
     }
diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php
index 07f779a676cd7c028cceca2857c68a04c0562673..0bd7ab3e4663269734c5a9fabe3adbf0e0b76c7d 100644
--- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php
+++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/EditTest.php
@@ -71,7 +71,7 @@ class EditTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ
                 $this->returnValue(['name' => 'nonExistentInt'])
             );
 
-        $invalidIdException = new IntegrationException($exceptionMessage);
+        $invalidIdException = new IntegrationException(__($exceptionMessage));
         $this->_integrationSvcMock->expects(
             $this->any()
         )->method(
diff --git a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php
index e1057b4f40a010a7ea3bb60493a5a63dad0a80bf..d29767e6091b2b1c86647e2ec61cbc6aaeefbafe 100644
--- a/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php
+++ b/app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/Integration/SaveTest.php
@@ -75,7 +75,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ
             )->with(
                 self::INTEGRATION_ID
             )->will(
-                $this->throwException(new \Magento\Framework\Exception\LocalizedException($exceptionMessage))
+                $this->throwException(new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage)))
             );
         // Verify error
         $this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage));
@@ -96,7 +96,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ
             )->with(
                 self::INTEGRATION_ID
             )->will(
-                $this->throwException(new IntegrationException($exceptionMessage))
+                $this->throwException(new IntegrationException(__($exceptionMessage)))
             );
         // Verify error
         $this->_messageManager->expects($this->once())->method('addError')->with($this->equalTo($exceptionMessage));
@@ -170,7 +170,7 @@ class SaveTest extends \Magento\Integration\Test\Unit\Controller\Adminhtml\Integ
             )->with(
                 $this->anything()
             )->will(
-                $this->throwException(new IntegrationException($exceptionMessage))
+                $this->throwException(new IntegrationException(__($exceptionMessage)))
             );
         $this->_integrationSvcMock->expects(
             $this->any()
diff --git a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php b/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php
index 1a938b865a368a1d5e564a254057b52f8b7750e1..01d17a14abf7fdaa7f6dcfdd141e3ffce7872414 100644
--- a/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php
+++ b/app/code/Magento/Integration/Test/Unit/Service/V1/OauthTest.php
@@ -46,6 +46,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
      */
     private $_tokenFactoryMock;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->_consumerFactory = $this->getMockBuilder(
@@ -108,6 +111,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->_emptyConsumerMock->expects($this->any())->method('getId')->will($this->returnValue(null));
     }
 
+    /**
+     * @return void
+     */
     public function testDelete()
     {
         $this->_consumerMock->expects(
@@ -133,6 +139,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\IntegrationException
      * @expectedExceptionMessage Consumer with ID '1' does not exist.
      */
@@ -144,6 +151,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->_service->deleteConsumer(self::VALUE_CONSUMER_ID);
     }
 
+    /**
+     * @return void
+     */
     public function testCreateAccessTokenAndClearExisting()
     {
 
@@ -182,6 +192,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->_service->createAccessToken(self::VALUE_CONSUMER_ID, true));
     }
 
+    /**
+     * @return void
+     */
     public function testCreateAccessTokenWithoutClearingExisting()
     {
         $this->_consumerMock->expects(
@@ -207,6 +220,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->_service->createAccessToken(self::VALUE_CONSUMER_ID, false));
     }
 
+    /**
+     * @return void
+     */
     public function testCreateAccessTokenInvalidConsumerId()
     {
         $this->_consumerMock->expects(
@@ -226,7 +242,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         )->will(
             $this->throwException(
                 new \Magento\Framework\Oauth\Exception(
-                    'A token with consumer ID 0 does not exist'
+                    __('A token with consumer ID 0 does not exist')
                 )
             )
         );
@@ -250,6 +266,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->_service->createAccessToken(0, false));
     }
 
+    /**
+     * @return void
+     */
     public function testLoadConsumer()
     {
         $this->_consumerMock->expects(
@@ -268,6 +287,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Oauth\Exception
      * @expectedExceptionMessage Unexpected error. Unable to load oAuth consumer account.
      */
@@ -279,12 +299,15 @@ class OauthTest extends \PHPUnit_Framework_TestCase
             'load'
         )->will(
             $this->throwException(
-                new \Magento\Framework\Oauth\Exception('Unexpected error. Unable to load oAuth consumer account.')
+                new \Magento\Framework\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.'))
             )
         );
         $this->_service->loadConsumer(self::VALUE_CONSUMER_ID);
     }
 
+    /**
+     * @return void
+     */
     public function testLoadConsumerByKey()
     {
         $this->_consumerMock->expects(
@@ -304,6 +327,7 @@ class OauthTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Oauth\Exception
      * @expectedExceptionMessage Unexpected error. Unable to load oAuth consumer account.
      */
@@ -315,12 +339,15 @@ class OauthTest extends \PHPUnit_Framework_TestCase
             'load'
         )->will(
             $this->throwException(
-                new \Magento\Framework\Oauth\Exception('Unexpected error. Unable to load oAuth consumer account.')
+                new \Magento\Framework\Oauth\Exception(__('Unexpected error. Unable to load oAuth consumer account.'))
             )
         );
         $this->_service->loadConsumerByKey(self::VALUE_CONSUMER_KEY);
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteToken()
     {
         $this->_consumerMock->expects(
@@ -346,6 +373,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->_service->deleteIntegrationToken(self::VALUE_CONSUMER_ID));
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteTokenNegative()
     {
         $this->_consumerMock->expects(
@@ -371,6 +401,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->_service->deleteIntegrationToken(null));
     }
 
+    /**
+     * @return void
+     */
     public function testGetAccessTokenNoAccess()
     {
         $this->_consumerMock->expects(
@@ -394,6 +427,9 @@ class OauthTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->_service->getAccessToken(self::VALUE_CONSUMER_ID), false);
     }
 
+    /**
+     * @return void
+     */
     public function testGetAccessSuccess()
     {
         $this->_consumerMock->expects(
diff --git a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php
index 56ad4ad93c8ec7033626be3cd35e671952915563..527a932ee63ea47bb473fb4cd48c21dd84eaaa11 100644
--- a/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php
+++ b/app/code/Magento/MediaStorage/Controller/Adminhtml/System/Config/System/Storage/Status.php
@@ -9,17 +9,17 @@ namespace Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage
 class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\System\Storage
 {
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
     /**
      * @param \Magento\Backend\App\Action\Context $context
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      */
     public function __construct(
         \Magento\Backend\App\Action\Context $context,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
     ) {
         parent::__construct($context);
         $this->resultJsonFactory = $resultJsonFactory;
@@ -28,7 +28,7 @@ class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\Sy
     /**
      * Retrieve synchronize process state and it's parameters in json format
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      * @SuppressWarnings(PHPMD.CyclomaticComplexity)
      */
     public function execute()
@@ -111,7 +111,7 @@ class Status extends \Magento\MediaStorage\Controller\Adminhtml\System\Config\Sy
             $state = \Magento\MediaStorage\Model\File\Storage\Flag::STATE_INACTIVE;
         }
         $result['state'] = $state;
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($result);
     }
diff --git a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php
index 09a65144fe469a9952d2825d50bf8df74c96e814..5e8850de308daea3b0c9c4b114744a1412318e97 100644
--- a/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php
+++ b/app/code/Magento/Newsletter/Controller/Subscriber/NewAction.php
@@ -84,8 +84,7 @@ class NewAction extends \Magento\Newsletter\Controller\Subscriber
         ) {
             throw new \Magento\Framework\Exception\LocalizedException(
                 __(
-                    'Sorry, but the administrator denied subscription for guests. '
-                    . 'Please <a href="%1">register</a>.',
+                    'Sorry, but the administrator denied subscription for guests. Please <a href="%1">register</a>.',
                     $this->_customerUrl->getRegisterUrl()
                 )
             );
diff --git a/app/code/Magento/Newsletter/Model/Template.php b/app/code/Magento/Newsletter/Model/Template.php
index a417f55fc79d5a47ea6bfc08a523c16daa0e4053..9f2dc723b155c0da2015d5cae3d906f5069ec660 100644
--- a/app/code/Magento/Newsletter/Model/Template.php
+++ b/app/code/Magento/Newsletter/Model/Template.php
@@ -168,7 +168,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate
                 }
             }
 
-            throw new \Magento\Framework\Exception\LocalizedException(join("\n", $errorMessages));
+            throw new \Magento\Framework\Exception\LocalizedException(__(join("\n", $errorMessages)));
         }
     }
 
diff --git a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
index 1042abf6c82f0de6983286fe2b6ed8b0030a3feb..f592aafcbc9c269a47e716130dd693af76f8e338 100644
--- a/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
+++ b/app/code/Magento/Newsletter/Test/Unit/Controller/Manage/SaveTest.php
@@ -141,8 +141,10 @@ class SaveTest extends \PHPUnit_Framework_TestCase
             ->method('getById')
             ->will($this->throwException(
                     new NoSuchEntityException(
-                        NoSuchEntityException::MESSAGE_SINGLE_FIELD,
-                        ['fieldName' => 'customerId', 'value' => 'value']
+                        __(
+                            NoSuchEntityException::MESSAGE_SINGLE_FIELD,
+                            ['fieldName' => 'customerId', 'value' => 'value']
+                        )
                     )
                 )
             );
diff --git a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
index c505620b5ff5f4b1869c1ddaae16b25346727a6b..ef18f302791d625c3fbd3be3ed516d461ae389af 100644
--- a/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
+++ b/app/code/Magento/OfflineShipping/Model/Resource/Carrier/Tablerate.php
@@ -321,7 +321,7 @@ class Tablerate extends \Magento\Framework\Model\Resource\Db\AbstractDb
         } catch (\Magento\Framework\Exception\LocalizedException $e) {
             $adapter->rollback();
             $stream->close();
-            throw new \Magento\Framework\Exception\LocalizedException($e->getMessage());
+            throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
         } catch (\Exception $e) {
             $adapter->rollback();
             $stream->close();
diff --git a/app/code/Magento/Payment/Model/Method/Factory.php b/app/code/Magento/Payment/Model/Method/Factory.php
index 590bb7a7b08cbc0476e2ed29e5619e360295b5ce..c5be7dd97cba2662e9f6d55b11c1f96f34f41a26 100644
--- a/app/code/Magento/Payment/Model/Method/Factory.php
+++ b/app/code/Magento/Payment/Model/Method/Factory.php
@@ -40,7 +40,7 @@ class Factory
         $method = $this->_objectManager->create($className, $data);
         if (!$method instanceof \Magento\Payment\Model\MethodInterface) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                sprintf("%s class doesn't implement \Magento\Payment\Model\MethodInterface", $className)
+                __('%1 class doesn\'t implement \Magento\Payment\Model\MethodInterface', $className)
             );
         }
         return $method;
diff --git a/app/code/Magento/Quote/Model/BillingAddressManagement.php b/app/code/Magento/Quote/Model/BillingAddressManagement.php
index 5e5140fc9e749bc5a05a04d3ccd79e73478c3a3a..502e4421bcb20c85cd263ed51121fd3aa6d9f72e 100644
--- a/app/code/Magento/Quote/Model/BillingAddressManagement.php
+++ b/app/code/Magento/Quote/Model/BillingAddressManagement.php
@@ -64,7 +64,7 @@ class BillingAddressManagement implements BillingAddressManagementInterface
             $this->quoteRepository->save($quote);
         } catch (\Exception $e) {
             $this->logger->critical($e);
-            throw new InputException('Unable to save address. Please, check input data.');
+            throw new InputException(__('Unable to save address. Please, check input data.'));
         }
         return $quote->getBillingAddress()->getId();
     }
diff --git a/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php
index f46eee82917f5701cfd5c90a815b3a1c696e56ae..f7ab6e07b0ecd9b135f3b800cd9f05e7c29e3791 100644
--- a/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php
+++ b/app/code/Magento/Quote/Model/Cart/Access/CartManagementPlugin.php
@@ -51,7 +51,7 @@ class CartManagementPlugin
         $storeId
     ) {
         if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) {
-            throw new AuthorizationException('Access denied');
+            throw new AuthorizationException(__('Access denied'));
         }
     }
 }
diff --git a/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php
index 562332c96dcf6c5161ffa3384820484282900310..0410af82ca10c736cda6c151f8bd34e81e30d60d 100644
--- a/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php
+++ b/app/code/Magento/Quote/Model/Cart/Access/CartRepositoryPlugin.php
@@ -48,7 +48,7 @@ class CartRepositoryPlugin
         $cartId
     ) {
         if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) {
-            throw new AuthorizationException('Access denied');
+            throw new AuthorizationException(__('Access denied'));
         }
     }
 
@@ -67,7 +67,7 @@ class CartRepositoryPlugin
         SearchCriteria $searchCriteria
     ) {
         if (!in_array($this->userContext->getUserType(), $this->allowedUserTypes)) {
-            throw new AuthorizationException('Access denied');
+            throw new AuthorizationException(__('Access denied'));
         }
     }
 }
diff --git a/app/code/Magento/Quote/Model/CouponManagement.php b/app/code/Magento/Quote/Model/CouponManagement.php
index dc9fb49b6eacb87861b3fc8f0c468aacf8c9e5af..c57172b122c8bf323810b012fd8c8414b49e0b0c 100644
--- a/app/code/Magento/Quote/Model/CouponManagement.php
+++ b/app/code/Magento/Quote/Model/CouponManagement.php
@@ -53,7 +53,7 @@ class CouponManagement implements CouponManagementInterface
         /** @var  \Magento\Quote\Model\Quote $quote */
         $quote = $this->quoteRepository->getActive($cartId);
         if (!$quote->getItemsCount()) {
-            throw new NoSuchEntityException("Cart $cartId doesn't contain products");
+            throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId));
         }
         $quote->getShippingAddress()->setCollectShippingRates(true);
 
@@ -61,10 +61,10 @@ class CouponManagement implements CouponManagementInterface
             $quote->setCouponCode($couponCode);
             $this->quoteRepository->save($quote->collectTotals());
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not apply coupon code');
+            throw new CouldNotSaveException(__('Could not apply coupon code'));
         }
         if ($quote->getCouponCode() != $couponCode) {
-            throw new NoSuchEntityException('Coupon code is not valid');
+            throw new NoSuchEntityException(__('Coupon code is not valid'));
         }
         return true;
     }
@@ -77,17 +77,17 @@ class CouponManagement implements CouponManagementInterface
         /** @var  \Magento\Quote\Model\Quote $quote */
         $quote = $this->quoteRepository->getActive($cartId);
         if (!$quote->getItemsCount()) {
-            throw new NoSuchEntityException("Cart $cartId doesn't contain products");
+            throw new NoSuchEntityException(__('Cart %1 doesn\'t contain products', $cartId));
         }
         $quote->getShippingAddress()->setCollectShippingRates(true);
         try {
             $quote->setCouponCode('');
             $this->quoteRepository->save($quote->collectTotals());
         } catch (\Exception $e) {
-            throw new CouldNotDeleteException('Could not delete coupon code');
+            throw new CouldNotDeleteException(__('Could not delete coupon code'));
         }
         if ($quote->getCouponCode() != '') {
-            throw new CouldNotDeleteException('Could not delete coupon code');
+            throw new CouldNotDeleteException(__('Could not delete coupon code'));
         }
         return true;
     }
diff --git a/app/code/Magento/Quote/Model/PaymentMethodManagement.php b/app/code/Magento/Quote/Model/PaymentMethodManagement.php
index 37a61c905ff4f160f3e3c873fe3d6a46e15344d4..55c493e80204dea29fd2178594d8fd7661e43b4e 100644
--- a/app/code/Magento/Quote/Model/PaymentMethodManagement.php
+++ b/app/code/Magento/Quote/Model/PaymentMethodManagement.php
@@ -59,13 +59,13 @@ class PaymentMethodManagement implements \Magento\Quote\Api\PaymentMethodManagem
         if ($quote->isVirtual()) {
             // check if billing address is set
             if (is_null($quote->getBillingAddress()->getCountryId())) {
-                throw new InvalidTransitionException('Billing address is not set');
+                throw new InvalidTransitionException(__('Billing address is not set'));
             }
             $quote->getBillingAddress()->setPaymentMethod($payment->getMethod());
         } else {
             // check if shipping address is set
             if (is_null($quote->getShippingAddress()->getCountryId())) {
-                throw new InvalidTransitionException('Shipping address is not set');
+                throw new InvalidTransitionException(__('Shipping address is not set'));
             }
             $quote->getShippingAddress()->setPaymentMethod($payment->getMethod());
         }
@@ -74,7 +74,7 @@ class PaymentMethodManagement implements \Magento\Quote\Api\PaymentMethodManagem
         }
 
         if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) {
-            throw new InvalidTransitionException('The requested Payment Method is not available.');
+            throw new InvalidTransitionException(__('The requested Payment Method is not available.'));
         }
 
         $quote->setTotalsCollectedFlag(false)->collectTotals()->save();
diff --git a/app/code/Magento/Quote/Model/Quote.php b/app/code/Magento/Quote/Model/Quote.php
index 91cc54e548ff163128c24a00337041b43671e6ce..ef130e2e6597203b74b35e6066678fedc712ac20 100644
--- a/app/code/Magento/Quote/Model/Quote.php
+++ b/app/code/Magento/Quote/Model/Quote.php
@@ -1588,7 +1588,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C
             }
         }
         if (!empty($errors)) {
-            throw new \Magento\Framework\Exception\LocalizedException(implode("\n", $errors));
+            throw new \Magento\Framework\Exception\LocalizedException(__(implode("\n", $errors)));
         }
 
         $this->_eventManager->dispatch('sales_quote_product_add_after', ['items' => $items]);
@@ -1685,7 +1685,7 @@ class Quote extends AbstractExtensibleModel implements \Magento\Quote\Api\Data\C
         $resultItem = $this->addProduct($product, $buyRequest);
 
         if (is_string($resultItem)) {
-            throw new \Magento\Framework\Exception\LocalizedException($resultItem);
+            throw new \Magento\Framework\Exception\LocalizedException(__($resultItem));
         }
 
         if ($resultItem->getParentItem()) {
diff --git a/app/code/Magento/Quote/Model/Quote/Item/Repository.php b/app/code/Magento/Quote/Model/Quote/Item/Repository.php
index 7ba19cd37d3670834e82eeae5596739c2021145d..fc4a0f7db7ef47c3b71ea4bbab5be324167a7425 100644
--- a/app/code/Magento/Quote/Model/Quote/Item/Repository.php
+++ b/app/code/Magento/Quote/Model/Quote/Item/Repository.php
@@ -84,7 +84,9 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface
             if (isset($itemId)) {
                 $cartItem = $quote->getItemById($itemId);
                 if (!$cartItem) {
-                    throw new NoSuchEntityException("Cart $cartId doesn't contain item  $itemId");
+                    throw new NoSuchEntityException(
+                        __('Cart %1 doesn\'t contain item  %2', $cartId, $itemId)
+                    );
                 }
                 $product = $this->productRepository->get($cartItem->getSku());
                 $cartItem->setData('qty', $qty);
@@ -97,7 +99,7 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface
             if ($e instanceof NoSuchEntityException) {
                 throw $e;
             }
-            throw new CouldNotSaveException('Could not save quote');
+            throw new CouldNotSaveException(__('Could not save quote'));
         }
         return $quote->getItemByProduct($product);
     }
@@ -117,13 +119,15 @@ class Repository implements \Magento\Quote\Api\CartItemRepositoryInterface
         $quote = $this->quoteRepository->getActive($cartId);
         $quoteItem = $quote->getItemById($itemId);
         if (!$quoteItem) {
-            throw new NoSuchEntityException("Cart $cartId doesn't contain item  $itemId");
+            throw new NoSuchEntityException(
+                __('Cart %1 doesn\'t contain item  %2', $cartId, $itemId)
+            );
         }
         try {
             $quote->removeItem($itemId);
             $this->quoteRepository->save($quote->collectTotals());
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Could not remove item from quote');
+            throw new CouldNotSaveException(__('Could not remove item from quote'));
         }
     }
 
diff --git a/app/code/Magento/Quote/Model/QuoteAddressValidator.php b/app/code/Magento/Quote/Model/QuoteAddressValidator.php
index b195066721af0a0885cd49c631154d7fb0fe986a..0098e459fd848d3476b317d934850e9ebda75857 100644
--- a/app/code/Magento/Quote/Model/QuoteAddressValidator.php
+++ b/app/code/Magento/Quote/Model/QuoteAddressValidator.php
@@ -52,7 +52,7 @@ class QuoteAddressValidator
             $customer->load($addressData->getCustomerId());
             if (!$customer->getId()) {
                 throw new \Magento\Framework\Exception\NoSuchEntityException(
-                    'Invalid customer id ' . $addressData->getCustomerId()
+                    __('Invalid customer id %1', $addressData->getCustomerId())
                 );
             }
         }
@@ -63,7 +63,7 @@ class QuoteAddressValidator
             $address->load($addressData->getId());
             if (!$address->getId()) {
                 throw new \Magento\Framework\Exception\NoSuchEntityException(
-                    'Invalid address id ' . $addressData->getId()
+                    __('Invalid address id %1', $addressData->getId())
                 );
             }
 
@@ -71,7 +71,7 @@ class QuoteAddressValidator
             if ($addressData->getCustomerId()) {
                 if ($address->getCustomerId() != $addressData->getCustomerId()) {
                     throw new \Magento\Framework\Exception\InputException(
-                        'Address with id ' . $addressData->getId() . ' belongs to another customer'
+                        __('Address with id %1 belongs to another customer', $addressData->getId())
                     );
                 }
             }
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 0f53de853e9c123685bab4ffaac707a6d55ce94d..7adb722ba25f868a9d7aa16717afbc099d1e915a 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -156,7 +156,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
         try {
             $this->quoteRepository->save($quote);
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Cannot create quote');
+            throw new CouldNotSaveException(__('Cannot create quote'));
         }
         return $quote->getId();
     }
@@ -171,14 +171,20 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
         $customerModel = $this->customerModelFactory->create();
 
         if (!in_array($storeId, $customerModel->load($customerId)->getSharedStoreIds())) {
-            throw new StateException('Cannot assign customer to the given cart. The cart belongs to different store.');
+            throw new StateException(
+                __('Cannot assign customer to the given cart. The cart belongs to different store.')
+            );
         }
         if ($quote->getCustomerId()) {
-            throw new StateException('Cannot assign customer to the given cart. The cart is not anonymous.');
+            throw new StateException(
+                __('Cannot assign customer to the given cart. The cart is not anonymous.')
+            );
         }
         try {
             $this->quoteRepository->getForCustomer($customerId);
-            throw new StateException('Cannot assign customer to the given cart. Customer already has active cart.');
+            throw new StateException(
+                __('Cannot assign customer to the given cart. Customer already has active cart.')
+            );
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
 
         }
@@ -217,7 +223,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
 
         try {
             $this->quoteRepository->getActiveForCustomer($this->userContext->getUserId());
-            throw new CouldNotSaveException('Cannot create quote');
+            throw new CouldNotSaveException(__('Cannot create quote'));
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
 
         }
diff --git a/app/code/Magento/Quote/Model/ShippingAddressManagement.php b/app/code/Magento/Quote/Model/ShippingAddressManagement.php
index 13b92793ab36844f3cdf414f76379990ebf86dda..40133907d2934db443b7c7ff8cf885720b2dde27 100644
--- a/app/code/Magento/Quote/Model/ShippingAddressManagement.php
+++ b/app/code/Magento/Quote/Model/ShippingAddressManagement.php
@@ -60,7 +60,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface
         $quote = $this->quoteRepository->getActive($cartId);
         if ($quote->isVirtual()) {
             throw new NoSuchEntityException(
-                'Cart contains virtual product(s) only. Shipping address is not applicable'
+                __('Cart contains virtual product(s) only. Shipping address is not applicable.')
             );
         }
         $this->addressValidator->validate($address);
@@ -73,7 +73,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface
             $this->quoteRepository->save($quote);
         } catch (\Exception $e) {
             $this->logger->critical($e);
-            throw new InputException('Unable to save address. Please, check input data.');
+            throw new InputException(__('Unable to save address. Please, check input data.'));
         }
         return $quote->getShippingAddress()->getId();
     }
@@ -91,7 +91,7 @@ class ShippingAddressManagement implements ShippingAddressManagementInterface
         $quote = $this->quoteRepository->getActive($cartId);
         if ($quote->isVirtual()) {
             throw new NoSuchEntityException(
-                'Cart contains virtual product(s) only. Shipping address is not applicable'
+                __('Cart contains virtual product(s) only. Shipping address is not applicable.')
             );
         }
 
diff --git a/app/code/Magento/Quote/Model/ShippingMethodManagement.php b/app/code/Magento/Quote/Model/ShippingMethodManagement.php
index a0aff7f9641e19ddb69df4c4faf8e38096d5ee6b..c951f228edbdbbca5371dad67e33df26d53f30c9 100644
--- a/app/code/Magento/Quote/Model/ShippingMethodManagement.php
+++ b/app/code/Magento/Quote/Model/ShippingMethodManagement.php
@@ -69,7 +69,7 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface
         /** @var \Magento\Quote\Model\Quote\Address $shippingAddress */
         $shippingAddress = $quote->getShippingAddress();
         if (!$shippingAddress->getCountryId()) {
-            throw new StateException('Shipping address not set.');
+            throw new StateException(__('Shipping address not set.'));
         }
 
         $shippingMethod = $shippingAddress->getShippingMethod();
@@ -101,7 +101,9 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface
     protected function divideNames($delimiter, $line)
     {
         if (strpos($line, $delimiter) === false) {
-            throw new InputException('Line "' .  $line . '" doesn\'t contain delimiter ' . $delimiter);
+            throw new InputException(
+                __('Line "%1" doesn\'t contain delimiter %2', $line, $delimiter)
+            );
         }
         return explode($delimiter, $line);
     }
@@ -123,7 +125,7 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface
 
         $shippingAddress = $quote->getShippingAddress();
         if (!$shippingAddress->getCountryId()) {
-            throw new StateException('Shipping address not set.');
+            throw new StateException(__('Shipping address not set.'));
         }
         $shippingAddress->collectShippingRates();
         $shippingRates = $shippingAddress->getGroupedAllShippingRates();
@@ -152,31 +154,33 @@ class ShippingMethodManagement implements ShippingMethodManagementInterface
         /** @var \Magento\Quote\Model\Quote $quote */
         $quote = $this->quoteRepository->getActive($cartId);
         if (0 == $quote->getItemsCount()) {
-            throw new InputException('Shipping method is not applicable for empty cart');
+            throw new InputException(__('Shipping method is not applicable for empty cart'));
         }
 
         if ($quote->isVirtual()) {
             throw new NoSuchEntityException(
-                'Cart contains virtual product(s) only. Shipping method is not applicable.'
+                __('Cart contains virtual product(s) only. Shipping method is not applicable.')
             );
         }
         $shippingAddress = $quote->getShippingAddress();
         if (!$shippingAddress->getCountryId()) {
-            throw new StateException('Shipping address is not set');
+            throw new StateException(__('Shipping address is not set'));
         }
         $billingAddress = $quote->getBillingAddress();
         if (!$billingAddress->getCountryId()) {
-            throw new StateException('Billing address is not set');
+            throw new StateException(__('Billing address is not set'));
         }
 
         $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode);
         if (!$shippingAddress->requestShippingRates()) {
-            throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode);
+            throw new NoSuchEntityException(
+                __('Carrier with such method not found: %1, %2', $carrierCode, $methodCode)
+            );
         }
         try {
             $this->quoteRepository->save($quote->collectTotals());
         } catch (\Exception $e) {
-            throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage());
+            throw new CouldNotSaveException(__('Cannot set shipping method. %1', $e->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php
index bfe59ec37ca4f5daeaef190ed4fed51d2226e7fc..244c1fb1778afd8d497c28b47199b009c9ac89f4 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/BillingAddressManagementTest.php
@@ -26,6 +26,9 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
      */
     protected $validatorMock;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->quoteRepositoryMock = $this->getMock('\Magento\Quote\Model\QuoteRepository', [], [], '', false);
@@ -34,6 +37,9 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
         $this->model = new BillingAddressManagement($this->quoteRepositoryMock, $this->validatorMock, $logger);
     }
 
+    /**
+     * @return void
+     */
     public function testGetAddress()
     {
         $quoteMock = $this->getMock('\Magento\Quote\Model\Quote', [], [], '', false);
@@ -48,6 +54,7 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
 
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage error123
      */
@@ -61,11 +68,14 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($quoteMock));
 
         $this->validatorMock->expects($this->once())->method('validate')
-            ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error123')));
+            ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error123'))));
 
         $this->model->assign('cartId', $address);
     }
 
+    /**
+     * @return void
+     */
     public function testSetAddress()
     {
         $address = $this->getMock('Magento\Quote\Model\Quote\Address', [], [], '', false, false);
@@ -93,6 +103,7 @@ class BillingAddressManagementTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\InputException
      * @expectedExceptionMessage Unable to save address. Please, check input data.
      */
diff --git a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php
index 7cdfa9aba7931604a040e2354aaba25d71c7f0c7..dc119a34be8a532f02115b22d1482bac427f8b56 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/CouponManagementTest.php
@@ -120,7 +120,7 @@ class CouponManagementTest extends \PHPUnit_Framework_TestCase
         $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true);
         $this->quoteMock->expects($this->once())->method('setCouponCode')->with($couponCode);
         $exceptionMessage = 'Could not apply coupon code';
-        $exception = new \Magento\Framework\Exception\CouldNotDeleteException($exceptionMessage);
+        $exception = new \Magento\Framework\Exception\CouldNotDeleteException(__($exceptionMessage));
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $this->quoteRepositoryMock->expects($this->once())
             ->method('save')
@@ -205,7 +205,7 @@ class CouponManagementTest extends \PHPUnit_Framework_TestCase
         $this->quoteMock->expects($this->once())->method('setCouponCode')->with('');
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $exceptionMessage = 'Could not delete coupon code';
-        $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage);
+        $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage));
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $this->quoteRepositoryMock->expects($this->once())
             ->method('save')
diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php
index 573acd5a8e792fac4dd316e8c49d214a22aef7ee..b90d93933827cbe676a413b79cbc4ed2e0d615b4 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Item/RepositoryTest.php
@@ -51,6 +51,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
      */
     protected $itemDataFactoryMock;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->quoteRepositoryMock =
@@ -74,6 +77,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @param null|string|bool|int|float $value
+     * @return void
      * @expectedException \Magento\Framework\Exception\InputException
      * @expectedExceptionMessage Invalid value of
      * @dataProvider addItemWithInvalidQtyDataProvider
@@ -84,6 +88,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->repository->save($this->dataMock);
     }
 
+    /**
+     * @return array
+     */
     public function addItemWithInvalidQtyDataProvider()
     {
         return [
@@ -98,6 +105,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotSaveException
      * @expectedExceptionMessage Could not save quote
      */
@@ -116,7 +124,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->quoteMock->expects($this->once())->method('addProduct')->with($this->productMock, 12);
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $exceptionMessage = 'Could not save quote';
-        $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage);
+        $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage));
         $this->quoteRepositoryMock->expects($this->once())
             ->method('save')
             ->with($this->quoteMock)
@@ -125,6 +133,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->repository->save($this->dataMock);
     }
 
+    /**
+     * @return void
+     */
     public function testSave()
     {
         $cartId = 13;
@@ -150,6 +161,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage Cart 11 doesn't contain item  5
      */
@@ -171,6 +183,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotSaveException
      * @expectedExceptionMessage Could not save quote
      */
@@ -196,7 +209,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $this->quoteItemMock->expects($this->never())->method('addProduct');
         $exceptionMessage = 'Could not save quote';
-        $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage);
+        $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage));
         $this->quoteRepositoryMock->expects($this->once())
             ->method('save')
             ->with($this->quoteMock)
@@ -205,6 +218,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->repository->save($this->dataMock);
     }
 
+    /**
+     * @return void
+     */
     public function testUpdateItem()
     {
         $cartId = 11;
@@ -236,6 +252,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\NoSuchEntityException
      * @expectedExceptionMessage Cart 11 doesn't contain item  5
      */
@@ -255,6 +272,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotSaveException
      * @expectedExceptionMessage Could not remove item from quote
      */
@@ -272,7 +290,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
             ->method('removeItem')->with($itemId)->will($this->returnValue($this->quoteMock));
         $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock));
         $exceptionMessage = 'Could not remove item from quote';
-        $exception = new \Magento\Framework\Exception\CouldNotSaveException($exceptionMessage);
+        $exception = new \Magento\Framework\Exception\CouldNotSaveException(__($exceptionMessage));
         $this->quoteRepositoryMock->expects($this->once())
             ->method('save')
             ->with($this->quoteMock)
@@ -281,6 +299,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->repository->delete($this->dataMock);
     }
 
+    /**
+     * @return void
+     */
     public function testDelete()
     {
         $cartId = 11;
@@ -298,6 +319,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->repository->delete($this->dataMock);
     }
 
+    /**
+     * @return void
+     */
     public function testGetList()
     {
         $quoteMock = $this->getMock('Magento\Quote\Model\Quote', [], [], '', false);
@@ -310,6 +334,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals([$itemMock], $this->repository->getList(33));
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteById()
     {
         $cartId = 11;
diff --git a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php
index 5de97e7588eec5d73ab165d9e6a42c2d32bbd71c..ddda3673b55dc91b68611979041a8bd8d51dec25 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/ShippingAddressManagementTest.php
@@ -72,7 +72,7 @@ class ShippingAddressManagementTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($quoteMock));
 
         $this->validatorMock->expects($this->once())->method('validate')
-            ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException('error345')));
+            ->will($this->throwException(new \Magento\Framework\Exception\NoSuchEntityException(__('error345'))));
 
         $this->service->assign('cart654', $this->quoteAddressMock);
     }
diff --git a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
index 2de8eaf41e183af60a117dd093ccc338adaba2a5..98537419a90f346fdf884520c90e00ace48ed54c 100644
--- a/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
+++ b/app/code/Magento/Reports/Model/Resource/Report/AbstractReport.php
@@ -398,16 +398,21 @@ abstract class AbstractReport extends \Magento\Framework\Model\Resource\Db\Abstr
      * @param mixed $from
      * @param mixed $to
      * @return array
+     * @SuppressWarnings(PHPMD.NPathComplexity)
      */
     protected function _getTZOffsetTransitions($timezone, $from = null, $to = null)
     {
         $tzTransitions = [];
         try {
             if (!empty($from)) {
-                $from = (new \DateTime($from))->getTimestamp();
+                $from = $from instanceof \DateTime
+                    ? $from->getTimestamp()
+                    : (new \DateTime($from))->getTimestamp();
             }
 
-            $to = new \DateTime($to);
+            $to = $to instanceof \DateTime
+                ? $to
+                : new \DateTime($to);
             $nextPeriod = $this->_getWriteAdapter()->formatDate(
                 $to->format('Y-m-d H:i:s')
             );
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order.php b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
index 3a2d6a0ea4e98ec55278223d7d6dceb4d6585b78..ee6934955fc08c5d7431b1a8f04ded1208ff0f30 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order.php
@@ -50,7 +50,7 @@ class Order extends \Magento\Backend\App\Action
     protected $resultRedirectFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -71,7 +71,7 @@ class Order extends \Magento\Backend\App\Action
      * @param \Magento\Framework\Translate\InlineInterface $translateInline
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
@@ -82,7 +82,7 @@ class Order extends \Magento\Backend\App\Action
         \Magento\Framework\Translate\InlineInterface $translateInline,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
index 737fa3bfed281122037be5dcffbba176b3dc76d6..0e56021124b3e5f7e69d05f733bac0b188d08ce5 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
@@ -22,7 +22,7 @@ class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
      * @param \Magento\Framework\Translate\InlineInterface $translateInline
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
@@ -36,7 +36,7 @@ class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
         \Magento\Framework\Translate\InlineInterface $translateInline,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\Result\LayoutFactory $resultLayoutFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
index c3f16b9f805888372dbd95cbfb08e4fc1f435b8a..63b1f9055bdd1e78a525a655e5cef4e96595048d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/AddComment.php
@@ -26,7 +26,7 @@ class AddComment extends \Magento\Backend\App\Action
     protected $pagePageFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -40,7 +40,7 @@ class AddComment extends \Magento\Backend\App\Action
      * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader
      * @param CreditmemoSender $creditmemoSender
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
     public function __construct(
@@ -48,7 +48,7 @@ class AddComment extends \Magento\Backend\App\Action
         \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader,
         CreditmemoSender $creditmemoSender,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
         $this->creditmemoLoader = $creditmemoLoader;
@@ -70,7 +70,7 @@ class AddComment extends \Magento\Backend\App\Action
     /**
      * Add comment to creditmemo history
      *
-     * @return \Magento\Framework\Controller\Result\Raw|\Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Raw|\Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
index 704d28d8c2d5af5a9a3b48484eb4fdc8c3d9970d..1757fdfb80248f31624fc10e1207faddee02f27d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
@@ -20,7 +20,7 @@ class UpdateQty extends \Magento\Backend\App\Action
     protected $pagePageFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -33,14 +33,14 @@ class UpdateQty extends \Magento\Backend\App\Action
      * @param Action\Context $context
      * @param \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
      */
     public function __construct(
         Action\Context $context,
         \Magento\Sales\Controller\Adminhtml\Order\CreditmemoLoader $creditmemoLoader,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\Controller\Result\RawFactory $resultRawFactory
     ) {
         $this->creditmemoLoader = $creditmemoLoader;
@@ -61,7 +61,7 @@ class UpdateQty extends \Magento\Backend\App\Action
     /**
      * Update items qty action
      *
-     * @return \Magento\Framework\Controller\Result\JSON|\Magento\Framework\Controller\Result\Raw
+     * @return \Magento\Framework\Controller\Result\Json|\Magento\Framework\Controller\Result\Raw
      */
     public function execute()
     {
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
index c39f8da6bf3a5283640e3a262cfc902d1f1e36e0..74011a35d81ec6170dfb86c740101e0db0e89736 100755
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
@@ -12,7 +12,7 @@ use Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender;
 use Magento\Sales\Model\Order\Invoice;
 use Magento\Backend\App\Action;
 use Magento\Framework\Registry;
-use Magento\Framework\Controller\Result\JSONFactory;
+use Magento\Framework\Controller\Result\JsonFactory;
 use Magento\Framework\View\Result\PageFactory;
 use Magento\Framework\Controller\Result\RawFactory;
 
@@ -24,7 +24,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv
     protected $invoiceCommentSender;
 
     /**
-     * @var JSONFactory
+     * @var JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -43,7 +43,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv
      * @param Registry $registry
      * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
      * @param InvoiceCommentSender $invoiceCommentSender
-     * @param JSONFactory $resultJsonFactory
+     * @param JsonFactory $resultJsonFactory
      * @param PageFactory $resultPageFactory
      * @param RawFactory $resultRawFactory
      */
@@ -52,7 +52,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv
         Registry $registry,
         \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
         InvoiceCommentSender $invoiceCommentSender,
-        JSONFactory $resultJsonFactory,
+        JsonFactory $resultJsonFactory,
         PageFactory $resultPageFactory,
         RawFactory $resultRawFactory
     ) {
@@ -101,7 +101,7 @@ class AddComment extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInv
             $response = ['error' => true, 'message' => __('Cannot add new comment.')];
         }
         if (is_array($response)) {
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             $resultJson->setData($response);
             return $resultJson;
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
index a3dce63b8cf55faba2e23b4a98dceb8bd04b3e76..a2c5ba9685349a2608e8084b9f4e43d1df1b710e 100755
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
@@ -8,7 +8,7 @@ namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
 
 use Magento\Framework\Exception\LocalizedException;
 use Magento\Backend\App\Action;
-use Magento\Framework\Controller\Result\JSONFactory;
+use Magento\Framework\Controller\Result\JsonFactory;
 use Magento\Framework\View\Result\PageFactory;
 use Magento\Framework\Controller\Result\RawFactory;
 use Magento\Backend\App\Action\Context;
@@ -17,7 +17,7 @@ use Magento\Framework\Registry;
 class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
 {
     /**
-     * @var JSONFactory
+     * @var JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -36,7 +36,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo
      * @param Registry $registry
      * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
      * @param PageFactory $resultPageFactory
-     * @param JSONFactory $resultJsonFactory
+     * @param JsonFactory $resultJsonFactory
      * @param RawFactory $resultRawFactory
      */
     public function __construct(
@@ -44,7 +44,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo
         Registry $registry,
         \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
         PageFactory $resultPageFactory,
-        JSONFactory $resultJsonFactory,
+        JsonFactory $resultJsonFactory,
         RawFactory $resultRawFactory
     ) {
         $this->resultPageFactory = $resultPageFactory;
@@ -96,7 +96,7 @@ class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvo
             $response = ['error' => true, 'message' => __('Cannot update item quantity.')];
         }
         if (is_array($response)) {
-            /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+            /** @var \Magento\Framework\Controller\Result\Json $resultJson */
             $resultJson = $this->resultJsonFactory->create();
             $resultJson->setData($response);
             return $resultJson;
diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php
index 4327c9d91d9a645a89e91f0fe20f3a47510c423e..7141a1bed3a26f0aaac1b4889f8fd0517df050d0 100644
--- a/app/code/Magento/Sales/Model/AdminOrder/Create.php
+++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php
@@ -475,7 +475,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
                 if ($qty > 0) {
                     $item = $this->initFromOrderItem($orderItem, $qty);
                     if (is_string($item)) {
-                        throw new \Magento\Framework\Exception\LocalizedException($item);
+                        throw new \Magento\Framework\Exception\LocalizedException(__($item));
                     }
                 }
             }
@@ -759,7 +759,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
                     $newItem = $this->getQuote()->addProduct($product, $info);
 
                     if (is_string($newItem)) {
-                        throw new \Magento\Framework\Exception\LocalizedException($newItem);
+                        throw new \Magento\Framework\Exception\LocalizedException(__($newItem));
                     }
                     $product->unsSkipCheckRequiredOption();
                     $newItem->checkData();
@@ -794,7 +794,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
 
                         $cartItem = $cart->addProduct($product, $info);
                         if (is_string($cartItem)) {
-                            throw new \Magento\Framework\Exception\LocalizedException($cartItem);
+                            throw new \Magento\Framework\Exception\LocalizedException(__($cartItem));
                         }
                         $cartItem->setPrice($item->getProduct()->getPrice());
                         $this->_needCollectCart = true;
@@ -818,7 +818,9 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
                         }
                     }
                     if (!$wishlist) {
-                        throw new \Magento\Framework\Exception\LocalizedException(__('We couldn\'t find this wish list.'));
+                        throw new \Magento\Framework\Exception\LocalizedException(
+                            __('We couldn\'t find this wish list.')
+                        );
                     }
                     $wishlist->setStore(
                         $this->getSession()->getStore()
@@ -872,7 +874,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
                 $orderItem = $this->_objectManager->create('Magento\Sales\Model\Order\Item')->load($orderItemId);
                 $item = $this->initFromOrderItem($orderItem);
                 if (is_string($item)) {
-                    throw new \Magento\Framework\Exception\LocalizedException($item);
+                    throw new \Magento\Framework\Exception\LocalizedException(__($item));
                 }
             }
         }
@@ -1004,7 +1006,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
         $item = $this->quoteInitializer->init($this->getQuote(), $product, $config);
 
         if (is_string($item)) {
-            throw new \Magento\Framework\Exception\LocalizedException($item);
+            throw new \Magento\Framework\Exception\LocalizedException(__($item));
         }
         $item->checkData();
         $this->setRecollect(true);
@@ -1425,7 +1427,7 @@ class Create extends \Magento\Framework\Object implements \Magento\Checkout\Mode
             $saveInAddressBook = (int)(!empty($address['save_in_address_book']));
             $billingAddress->setData('save_in_address_book', $saveInAddressBook);
 
-            if ($this->getShippingAddress()->getSameAsBilling()) {
+            if (!$this->getQuote()->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
                 $shippingAddress = clone $billingAddress;
                 $shippingAddress->setSameAsBilling(true);
                 $shippingAddress->setSaveInAddressBook(false);
diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php
index fe65a74f1e94e07eadbae950d6364d04b43a9e54..f308b43487ffc6e238e31f87b45185d123431bf4 100644
--- a/app/code/Magento/Sales/Model/Order/Payment.php
+++ b/app/code/Magento/Sales/Model/Order/Payment.php
@@ -690,7 +690,6 @@ class Payment extends Info implements OrderPaymentInterface
                     if (!$captureTxn) {
                         throw new \Magento\Framework\Exception\LocalizedException(
                             __('If the invoice was created offline, try creating an offline credit memo.'),
-                            [],
                             $e
                         );
                     }
diff --git a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php
index f04fc104817cb2038fb8dc2aae1a0a6e489f1767..da58fb8949588d7f2715dcbef38e22ff97769c2c 100644
--- a/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Payment/TransactionRepository.php
@@ -77,7 +77,7 @@ class TransactionRepository
     public function get($id)
     {
         if (!$id) {
-            throw new \Magento\Framework\Exception\InputException('ID required');
+            throw new \Magento\Framework\Exception\InputException(__('ID required'));
         }
         if (!isset($this->registry[$id])) {
             $filter = $this->filterBuilder->setField('transaction_id')->setValue($id)->setConditionType('eq')->create();
@@ -85,7 +85,9 @@ class TransactionRepository
             $this->find($this->searchCriteriaBuilder->create());
 
             if (!isset($this->registry[$id])) {
-                throw new \Magento\Framework\Exception\NoSuchEntityException('Requested entity doesn\'t exist');
+                throw new \Magento\Framework\Exception\NoSuchEntityException(
+                    __('Requested entity doesn\'t exist')
+                );
             }
         }
         return $this->registry[$id];
diff --git a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php
index af33e3b1522889f58c5da651ff2c0dba17aa05d5..fa724f3b481d46fefd26a8c0fe842f06e4f6e2ce 100644
--- a/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php
+++ b/app/code/Magento/Sales/Model/Order/Pdf/Total/Factory.php
@@ -40,8 +40,8 @@ class Factory
         $class = $class ?: $this->_defaultTotalModel;
         if (!is_a($class, 'Magento\Sales\Model\Order\Pdf\Total\DefaultTotal', true)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                sprintf(
-                    'The PDF total model %s must be or extend \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal.',
+                __(
+                    'The PDF total model %1 must be or extend \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal.',
                     $class
                 )
             );
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/Item.php b/app/code/Magento/Sales/Model/Order/Shipment/Item.php
index 099a6af8875ff0f1044198b77e118b5788448700..415b2bfcb79dfcc4ff72e9ac26fcf075358e0534 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/Item.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/Item.php
@@ -15,6 +15,7 @@ use Magento\Sales\Api\Data\ShipmentItemInterface;
 /**
  * @method \Magento\Sales\Model\Resource\Order\Shipment\Item _getResource()
  * @method \Magento\Sales\Model\Resource\Order\Shipment\Item getResource()
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  */
 class Item extends AbstractExtensibleModel implements ShipmentItemInterface
 {
@@ -158,7 +159,9 @@ class Item extends AbstractExtensibleModel implements ShipmentItemInterface
         if ($qty <= $this->getOrderItem()->getQtyToShip() || $this->getOrderItem()->isDummy(true)) {
             $this->setData('qty', $qty);
         } else {
-            throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid qty to ship for item "%1".', $this->getName()));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('We found an invalid qty to ship for item "%1".', $this->getName())
+            );
         }
         return $this;
     }
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Address.php b/app/code/Magento/Sales/Model/Resource/Order/Address.php
index bbe542dc5a5752c73b1c0332d139901b76ae41b5..0ae0007afce4c6df73de79ae9dfb3a79fd7bee57 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Address.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Address.php
@@ -107,7 +107,7 @@ class Address extends SalesResource implements OrderAddressResourceInterface
         $warnings = $this->_validator->validate($object);
         if (!empty($warnings)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __("Cannot save address") . ":\n" . implode("\n", $warnings)
+                __("Cannot save address:\n%1", implode("\n", $warnings))
             );
         }
         return $this;
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
index b26ff144fb4765a0c666e13f590a7243d0fbe898..4bd2bc8463cfeec1d5a6d18b75f2196f71ae6e31 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Creditmemo/Comment.php
@@ -77,7 +77,7 @@ class Comment extends Entity implements CreditmemoCommentResourceInterface
         $errors = $this->validator->validate($object);
         if (!empty($errors)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __("Cannot save comment") . ":\n" . implode("\n", $errors)
+                __("Cannot save comment:\n%1", implode("\n", $errors))
             );
         }
         return $this;
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
index ebfdc76baac952d5b71e77ea1958047d8b2729ee..32d95112c41bf7215db251323aa6d313f596b9d1 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Invoice/Comment.php
@@ -77,7 +77,7 @@ class Comment extends Entity implements InvoiceCommentResourceInterface
         $errors = $this->validator->validate($object);
         if (!empty($errors)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __("Cannot save comment") . ":\n" . implode("\n", $errors)
+                __("Cannot save comment:\n%1", implode("\n", $errors))
             );
         }
 
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
index 4ed6b5f5c48bdec471b9b172bde92419046c0909..e18d89970fb50860305407633261e6e2f5d29479 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Comment.php
@@ -77,7 +77,7 @@ class Comment extends Entity implements ShipmentCommentResourceInterface
         $errors = $this->validator->validate($object);
         if (!empty($errors)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __("Cannot save comment") . ":\n" . implode("\n", $errors)
+                __("Cannot save comment:\n%1", implode("\n", $errors))
             );
         }
 
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
index f578d8b127fe841c3a74cb19dc2ef8022a9ff537..9ff1715b0dc714a8ce93d562ec99f770312541f3 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Shipment/Track.php
@@ -77,7 +77,7 @@ class Track extends SalesResource implements ShipmentTrackResourceInterface
         $errors = $this->validator->validate($object);
         if (!empty($errors)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __("Cannot save track") . ":\n" . implode("\n", $errors)
+                __("Cannot save track:\n%1", implode("\n", $errors))
             );
         }
 
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status.php b/app/code/Magento/Sales/Model/Resource/Order/Status.php
index 717b0815250f2db097829db2535b961a64541404..c4a1ff9408d4c4136a6772d55017a9fa3dd3c30e 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Status.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Status.php
@@ -205,7 +205,7 @@ class Status extends \Magento\Framework\Model\Resource\Db\AbstractDb
             $this->_getWriteAdapter()->commit();
         } catch (\Exception $e) {
             $this->_getWriteAdapter()->rollBack();
-            throw new LocalizedException(__('Cannot unassing status from state'));
+            throw new LocalizedException(__('Cannot unassign status from state'));
         }
 
         return $this;
diff --git a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
index a92dea95519e04cc4a0fdceca9d53a5f6e6b94c8..ff92ebe32c2ebc63be6afd3d3cbeba8b8a7dba14 100644
--- a/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
+++ b/app/code/Magento/Sales/Model/Resource/Order/Status/History.php
@@ -71,7 +71,7 @@ class History extends Entity implements OrderStatusHistoryResourceInterface
         $warnings = $this->validator->validate($object);
         if (!empty($warnings)) {
             throw new \Magento\Framework\Exception\LocalizedException(
-                __('Cannot save comment') . ":\n" . implode("\n", $warnings)
+                __("Cannot save comment:\n%1", implode("\n", $warnings))
             );
         }
         return $this;
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php
old mode 100644
new mode 100755
index 1289656b3188d2292bb61de601caf830aeafc853..b7b8759dfc4016b42702cb84f7e7c5b7ed76bbba
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/AddCommentTest.php
@@ -51,7 +51,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
     protected $resultPageFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactoryMock;
 
@@ -66,7 +66,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
     protected $resultPageMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonMock;
 
@@ -75,6 +75,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultRawMock;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     public function setUp()
     {
         $titleMock = $this->getMockBuilder('Magento\Framework\App\Action\Title')
@@ -112,7 +117,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
-        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -123,7 +128,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
         $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page')
             ->disableOriginalConstructor()
             ->getMock();
-        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->getMock();
         $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw')
@@ -144,10 +149,15 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute module exception
+     *
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $message = 'Model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
         $response = ['error' => true, 'message' => $message];
 
         $this->requestMock->expects($this->any())
@@ -162,11 +172,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->willReturnSelf();
 
         $this->assertInstanceOf(
-            'Magento\Framework\Controller\Result\JSON',
+            'Magento\Framework\Controller\Result\Json',
             $this->controller->execute()
         );
     }
 
+    /**
+     * Test execute exception
+     *
+     * @return void
+     */
     public function testExecuteException()
     {
         $message = 'Cannot add new comment.';
@@ -185,11 +200,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->willReturnSelf();
 
         $this->assertInstanceOf(
-            'Magento\Framework\Controller\Result\JSON',
+            'Magento\Framework\Controller\Result\Json',
             $this->controller->execute()
         );
     }
 
+    /**
+     * Test execute no comment
+     *
+     * @return void
+     */
     public function testExecuteNoComment()
     {
         $message = 'The Comment Text field cannot be empty.';
@@ -209,11 +229,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->willReturnSelf();
 
         $this->assertInstanceOf(
-            'Magento\Framework\Controller\Result\JSON',
+            'Magento\Framework\Controller\Result\Json',
             $this->controller->execute()
         );
     }
 
+    /**
+     * Test execute
+     *
+     * @return void
+     */
     public function testExecute()
     {
         $comment = 'Test comment';
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php
index debfcaf0d54e0c522e2b8ea89ddff7be5f8915e1..bc849016a87c4412fd84dcc98f57a1cd7fca1185 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/CancelTest.php
@@ -85,6 +85,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultForwardMock;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo')
@@ -170,11 +173,14 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $id = 123;
         $message = 'Model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->any())
             ->method('getParam')
@@ -202,6 +208,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteException()
     {
         $id = 321;
@@ -234,6 +243,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteNoCreditmemo()
     {
         $this->requestMock->expects($this->any())
@@ -257,6 +269,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecute()
     {
         $id = '111';
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php
index 27e46f3c67dc28c691e5a56a2b86a775d12dbe5e..7b6c366e5eceaa2e21cdb8ab146ffe1ac547a752 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/UpdateQtyTest.php
@@ -72,7 +72,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
     protected $resultPageFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactoryMock;
 
@@ -87,7 +87,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
     protected $resultPageMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonMock;
 
@@ -96,6 +96,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultRawMock;
 
+    /**
+     * Set up method
+     *
+     * @return void
+     */
     public function setUp()
     {
         $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo')
@@ -158,7 +163,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
-        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -169,7 +174,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
         $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page')
             ->disableOriginalConstructor()
             ->getMock();
-        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->getMock();
         $this->resultRawMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Raw')
@@ -189,10 +194,15 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute model exception
+     *
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $message = 'Model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
         $response = ['error' => true, 'message' => $message];
 
         $this->requestMock->expects($this->any())
@@ -210,11 +220,16 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->willReturnSelf();
 
         $this->assertInstanceOf(
-            'Magento\Framework\Controller\Result\JSON',
+            'Magento\Framework\Controller\Result\Json',
             $this->controller->execute()
         );
     }
 
+    /**
+     * Test execute exception
+     *
+     * @return void
+     */
     public function testExecuteException()
     {
         $message = 'Cannot update the item\'s quantity.';
@@ -236,11 +251,16 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->willReturnSelf();
 
         $this->assertInstanceOf(
-            'Magento\Framework\Controller\Result\JSON',
+            'Magento\Framework\Controller\Result\Json',
             $this->controller->execute()
         );
     }
 
+    /**
+     * Test execute
+     *
+     * @return void
+     */
     public function testExecute()
     {
         $response = 'output';
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php
index 1b5fc9201e47aa49a7d447b1ce74558d39bc1989..fe28217d346f7f1872c40c83709182509da12e5d 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Creditmemo/VoidTest.php
@@ -91,6 +91,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultForwardMock;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $this->creditmemoMock = $this->getMockBuilder('Magento\Sales\Model\Order\Creditmemo')
@@ -180,6 +183,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteNoCreditmemo()
     {
         $this->requestMock->expects($this->any())
@@ -203,11 +209,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $id = 123;
         $message = 'Model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->any())
             ->method('getParam')
@@ -236,6 +245,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteException()
     {
         $id = 321;
@@ -269,6 +281,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecute()
     {
         $id = '111';
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
index 65fd1832056b5d25c635b04a957649e4134a816c..0f552a950113c2c01b5eb195f3327834abdab2b6 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
@@ -65,7 +65,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
     protected $resultPageFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactoryMock;
 
@@ -75,10 +75,15 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
     protected $resultRawFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonMock;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     public function setUp()
     {
         $objectManager = new ObjectManager($this);
@@ -146,7 +151,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->setMethods(['create'])
             ->getMock();
 
-        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->setMethods([])
             ->getMock();
@@ -156,7 +161,7 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
             ->setMethods(['create'])
             ->getMock();
 
-        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -177,6 +182,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute
+     *
+     * @return void
+     */
     public function testExecute()
     {
         $data = ['comment' => 'test comment'];
@@ -255,11 +265,16 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRaw, $this->controller->execute());
     }
 
+    /**
+     * Test execute model exception
+     *
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $message = 'model exception';
         $response = ['error' => true, 'message' => $message];
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->once())
             ->method('getParam')
@@ -273,6 +288,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($this->resultJsonMock, $this->controller->execute());
     }
 
+    /**
+     * Test execute exception
+     *
+     * @return void
+     */
     public function testExecuteException()
     {
         $response = ['error' => true, 'message' => 'Cannot add new comment.'];
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php
index cea2b45bc88ac42679051d5240dd5d821931016b..3575638720b4aebf55f90d9f00ff0f30a716bd5d 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php
@@ -64,6 +64,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
      */
     protected $controller;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $objectManager = new ObjectManager($this);
@@ -145,6 +148,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecute()
     {
         $invoiceId = 2;
@@ -217,6 +223,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRedirect, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteNoInvoice()
     {
         $invoiceId = 2;
@@ -251,12 +260,15 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultForward, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $invoiceId = 2;
 
         $message = 'model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->once())
             ->method('getParam')
@@ -300,6 +312,9 @@ class CancelTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRedirect, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteException()
     {
         $invoiceId = 2;
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php
index 8b0d5249c96464dfdd5f8aac7cd7b021872d823e..0e57e1af6c5198a9b4d45cdd921afa10b7b9745e 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php
@@ -64,6 +64,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase
      */
     protected $controller;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $objectManager = new ObjectManager($this);
@@ -145,6 +148,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecute()
     {
         $invoiceId = 2;
@@ -218,6 +224,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRedirect, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteNoInvoice()
     {
         $invoiceId = 2;
@@ -252,12 +261,15 @@ class CaptureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultForward, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $invoiceId = 2;
 
         $message = 'model exception';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->once())
             ->method('getParam')
@@ -301,6 +313,9 @@ class CaptureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRedirect, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteException()
     {
         $invoiceId = 2;
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php
index e4c7cdb93d1c58f2444838c129d5d29192eba63d..1c5cf1cefa0223c32ab910f86143b27b7be09ff9 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/UpdateQtyTest.php
@@ -66,10 +66,15 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
     protected $resultRawFactoryMock;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $resultJsonFactoryMock;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     public function setUp()
     {
         $objectManager = new ObjectManager($this);
@@ -135,7 +140,7 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->setMethods(['create'])
             ->getMock();
 
-        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory')
+        $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory')
             ->disableOriginalConstructor()
             ->setMethods(['create'])
             ->getMock();
@@ -151,6 +156,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute
+     *
+     * @return void
+     */
     public function testExecute()
     {
         $orderId = 1;
@@ -247,6 +257,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRaw, $this->controller->execute());
     }
 
+    /**
+     * Test execute model exception
+     *
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $message = 'Cannot update item quantity.';
@@ -271,8 +286,8 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->method('prepend')
             ->with('Invoices');
 
-        /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */
-        $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */
+        $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->setMethods([])
             ->getMock();
@@ -285,6 +300,11 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultJsonMock, $this->controller->execute());
     }
 
+    /**
+     * Test execute exception
+     *
+     * @return void
+     */
     public function testExecuteException()
     {
         $message = 'Cannot update item quantity.';
@@ -309,8 +329,8 @@ class UpdateQtyTest extends \PHPUnit_Framework_TestCase
             ->method('prepend')
             ->with('Invoices');
 
-        /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */
-        $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON')
+        /** @var \Magento\Framework\Controller\Result\Json|\PHPUnit_Framework_MockObject_MockObject */
+        $resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json')
             ->disableOriginalConstructor()
             ->setMethods([])
             ->getMock();
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php
index a268d6ec5a216ec4ff9ad015d6c56b91c1dc359e..21d1f3f644b4a43d25118b3db9ae0d2799726461 100755
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php
@@ -69,6 +69,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
      */
     protected $resultForwardFactoryMock;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $objectManager = new ObjectManager($this);
@@ -158,6 +161,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testExecute()
     {
         $invoiceId = 2;
@@ -230,6 +236,9 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultRedirect, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteNoInvoice()
     {
         $invoiceId = 2;
@@ -270,11 +279,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($resultForward, $this->controller->execute());
     }
 
+    /**
+     * @return void
+     */
     public function testExecuteModelException()
     {
         $invoiceId = 2;
         $message = 'test message';
-        $e = new \Magento\Framework\Exception\LocalizedException($message);
+        $e = new \Magento\Framework\Exception\LocalizedException(__($message));
 
         $this->requestMock->expects($this->once())
             ->method('getParam')
diff --git a/app/code/Magento/Shipping/Model/Observer.php b/app/code/Magento/Shipping/Model/Observer.php
index c218e1d1d3f210b2d8b857ec732c7c254b71aa06..e29359060abb9170593593d4b2b50606c98ffdde 100644
--- a/app/code/Magento/Shipping/Model/Observer.php
+++ b/app/code/Magento/Shipping/Model/Observer.php
@@ -37,8 +37,8 @@ class Observer
     public function aggregateSalesReportShipmentData()
     {
         $this->_localeResolver->emulate(0);
-        $currentDate = $this->_coreLocale->date();
-        $date = $currentDate->subHour(25);
+        $currentDate = new \DateTime();
+        $date = $currentDate->modify('-25 hours');
         $this->_shippingFactory->create()->aggregate($date);
         $this->_localeResolver->revert();
         return $this;
diff --git a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php
index e8e05c7421b598328dc0ef202234e075e3205c96..ad4dbab755e3847e21bcae41adbebcc86d9c8586 100644
--- a/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php
+++ b/app/code/Magento/Shipping/Model/Shipping/LabelGenerator.php
@@ -76,7 +76,7 @@ class LabelGenerator
         $shipment->setPackages($request->getParam('packages'));
         $response = $this->labelFactory->create()->requestToShipment($shipment);
         if ($response->hasErrors()) {
-            throw new \Magento\Framework\Exception\LocalizedException($response->getErrors());
+            throw new \Magento\Framework\Exception\LocalizedException(__($response->getErrors()));
         }
         if (!$response->hasInfo()) {
             throw new \Magento\Framework\Exception\LocalizedException(__('Response info is not exist.'));
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
index b75bca3f82676fc5cd7bff68f1842459fad7732e..a79430f7ac06b3d8e5ae4b5e7fa1caafca31957a 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Tax.php
@@ -51,7 +51,7 @@ class Tax extends \Magento\Backend\App\Action
     {
         $className = trim($this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($className));
         if ($className == '') {
-            throw new InputException('Invalid name of tax class specified.');
+            throw new InputException(__('Invalid name of tax class specified.'));
         }
         return $className;
     }
diff --git a/app/code/Magento/Tax/Model/Calculation/Rate.php b/app/code/Magento/Tax/Model/Calculation/Rate.php
index 06e40c545eb868797a682864365c96483b28d4a1..18dde7c54f14d54945d1625e034e07ce7833f502 100644
--- a/app/code/Magento/Tax/Model/Calculation/Rate.php
+++ b/app/code/Magento/Tax/Model/Calculation/Rate.php
@@ -115,11 +115,15 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \
             ($this->getTaxPostcode() === '' && !$this->getZipIsRange());
 
         if ($isEmptyValues || $isWrongRange) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Please fill all required fields with valid information.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Please fill all required fields with valid information.')
+            );
         }
 
         if (!is_numeric($this->getRate()) || $this->getRate() < 0) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Rate Percent should be a positive number.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Rate Percent should be a positive number.')
+            );
         }
 
         if ($this->getZipIsRange()) {
@@ -131,11 +135,15 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \
             }
 
             if (!is_numeric($zipFrom) || !is_numeric($zipTo) || $zipFrom < 0 || $zipTo < 0) {
-                throw new \Magento\Framework\Exception\LocalizedException(__('Zip code should not contain characters other than digits.'));
+                throw new \Magento\Framework\Exception\LocalizedException(
+                    __('Zip code should not contain characters other than digits.')
+                );
             }
 
             if ($zipFrom > $zipTo) {
-                throw new \Magento\Framework\Exception\LocalizedException(__('Range To should be equal or greater than Range From.'));
+                throw new \Magento\Framework\Exception\LocalizedException(
+                    __('Range To should be equal or greater than Range From.')
+                );
             }
 
             $this->setTaxPostcode($zipFrom . '-' . $zipTo);
@@ -182,7 +190,9 @@ class Rate extends \Magento\Framework\Model\AbstractExtensibleModel implements \
     public function beforeDelete()
     {
         if ($this->_isInRule()) {
-            throw new CouldNotDeleteException('The tax rate cannot be removed. It exists in a tax rule.');
+            throw new CouldNotDeleteException(
+                __('The tax rate cannot be removed. It exists in a tax rule.')
+            );
         }
         return parent::beforeDelete();
     }
diff --git a/app/code/Magento/Tax/Model/Calculation/RateRepository.php b/app/code/Magento/Tax/Model/Calculation/RateRepository.php
index 48967e8bec82aa77e6c47e7626dd4f18731c3c48..a185acd15844412198f779b0efd4dc58e224a7fa 100644
--- a/app/code/Magento/Tax/Model/Calculation/RateRepository.php
+++ b/app/code/Magento/Tax/Model/Calculation/RateRepository.php
@@ -233,17 +233,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface
 
         $countryCode = $taxRate->getTaxCountryId();
         if (!\Zend_Validate::is($countryCode, 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'country_id']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'country_id']));
         } elseif (!\Zend_Validate::is(
             $this->countryFactory->create()->loadByCode($countryCode)->getId(),
             'NotEmpty'
         )) {
             $exception->addError(
-                InputException::INVALID_FIELD_VALUE,
-                [
-                    'fieldName' => 'country_id',
-                    'value' => $countryCode
-                ]
+                __(
+                    InputException::INVALID_FIELD_VALUE,
+                    [
+                        'fieldName' => 'country_id',
+                        'value' => $countryCode
+                    ]
+                )
             );
         }
 
@@ -256,17 +258,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface
             )
         ) {
             $exception->addError(
-                InputException::INVALID_FIELD_VALUE,
-                ['fieldName' => 'region_id', 'value' => $regionCode]
+                __(
+                    InputException::INVALID_FIELD_VALUE,
+                    ['fieldName' => 'region_id', 'value' => $regionCode]
+                )
             );
         }
 
         if (!\Zend_Validate::is($taxRate->getRate(), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'percentage_rate']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'percentage_rate']));
         }
 
         if (!\Zend_Validate::is(trim($taxRate->getCode()), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'code']);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'code']));
         }
 
         if ($taxRate->getZipIsRange()) {
@@ -277,17 +281,19 @@ class RateRepository implements \Magento\Tax\Api\TaxRateRepositoryInterface
             foreach ($zipRangeFromTo as $key => $value) {
                 if (!is_numeric($value) || $value < 0) {
                     $exception->addError(
-                        InputException::INVALID_FIELD_VALUE,
-                        ['fieldName' => $key, 'value' => $value]
+                        __(
+                            InputException::INVALID_FIELD_VALUE,
+                            ['fieldName' => $key, 'value' => $value]
+                        )
                     );
                 }
             }
             if ($zipRangeFromTo['zip_from'] > $zipRangeFromTo['zip_to']) {
-                $exception->addError('Range To should be equal or greater than Range From.');
+                $exception->addError(__('Range To should be equal or greater than Range From.'));
             }
         } else {
             if (!\Zend_Validate::is(trim($taxRate->getTaxPostcode()), 'NotEmpty')) {
-                $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']);
+                $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'postcode']));
             }
         }
 
diff --git a/app/code/Magento/Tax/Model/ClassModel.php b/app/code/Magento/Tax/Model/ClassModel.php
index 9835203636346d9a2d6a66a7bd2b75bf5eae09e7..603fc708d47286e0dffdd25f8724756445f6cac1 100644
--- a/app/code/Magento/Tax/Model/ClassModel.php
+++ b/app/code/Magento/Tax/Model/ClassModel.php
@@ -83,22 +83,26 @@ class ClassModel extends \Magento\Framework\Model\AbstractExtensibleModel implem
     protected function checkClassCanBeDeleted()
     {
         if (!$this->getId()) {
-            throw new CouldNotDeleteException('This class no longer exists.');
+            throw new CouldNotDeleteException(__('This class no longer exists.'));
         }
 
         $typeModel = $this->_classFactory->create($this);
 
         if ($typeModel->getAssignedToRules()->getSize() > 0) {
             throw new CouldNotDeleteException(
-                'You cannot delete this tax class because it is used in Tax Rules.' .
-                ' You have to delete the rules it is used in first.'
+                __(
+                    'You cannot delete this tax class because it is used in Tax Rules.'
+                    . ' You have to delete the rules it is used in first.'
+                )
             );
         }
 
         if ($typeModel->isAssignedToObjects()) {
             throw new CouldNotDeleteException(
-                'You cannot delete this tax class because it is used in existing %object(s).',
-                ['object' => $typeModel->getObjectTypeName()]
+                __(
+                    'You cannot delete this tax class because it is used in existing %1(s).',
+                    $typeModel->getObjectTypeName()
+                )
             );
         }
 
diff --git a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php
index 217b4784ec1cde88c4714d3371b58e4aa7d890a9..8c39b7f01cb7019876f192c86250fa31a19d5794 100644
--- a/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php
+++ b/app/code/Magento/Tax/Model/Resource/Calculation/Rule/Collection.php
@@ -156,6 +156,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
                 break;
             default:
                 throw new \Magento\Framework\Exception\LocalizedException(__('Invalid type supplied'));
+                break;
         }
 
         $this->joinCalculationData('cd');
diff --git a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
index 0debdc08528530634e654aad46666f1c75a8e12b..c665dfd00e8f8a65f487faacb618c1475991b10b 100644
--- a/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
+++ b/app/code/Magento/Tax/Model/Sales/Order/TaxManagement.php
@@ -127,11 +127,13 @@ class TaxManagement implements \Magento\Tax\Api\OrderTaxManagementInterface
         $order = $this->orderFactory->create()->load($orderId);
         if (!$order) {
             throw new NoSuchEntityException(
-                NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-                [
-                    'fieldName' => 'orderId',
-                    'fieldValue' => $orderId,
-                ]
+                __(
+                    NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                    [
+                        'fieldName' => 'orderId',
+                        'fieldValue' => $orderId,
+                    ]
+                )
             );
         }
 
diff --git a/app/code/Magento/Tax/Model/TaxClass/Repository.php b/app/code/Magento/Tax/Model/TaxClass/Repository.php
index 83017d71277ddd9a7d851fc94868e8146afb3b38..a0fc6fe76d46ec8718a7cccf2af8a44068b73425 100644
--- a/app/code/Magento/Tax/Model/TaxClass/Repository.php
+++ b/app/code/Magento/Tax/Model/TaxClass/Repository.php
@@ -96,7 +96,7 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface
 
             /* should not be allowed to switch the tax class type */
             if ($originalTaxClassModel->getClassType() !== $taxClass->getClassType()) {
-                throw new InputException('Updating classType is not allowed.');
+                throw new InputException(__('Updating classType is not allowed.'));
             }
         }
         $this->validateTaxClassData($taxClass);
@@ -105,8 +105,10 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface
         } catch (ModelException $e) {
             if (strpos($e->getMessage(), (string)__('Class name and class type')) !== false) {
                 throw new InputException(
-                    'A class with the same name already exists for ClassType %classType.',
-                    ['classType' => $taxClass->getClassType()]
+                    __(
+                        'A class with the same name already exists for ClassType %1.',
+                        $taxClass->getClassType()
+                    )
                 );
             } else {
                 throw $e;
@@ -162,18 +164,20 @@ class Repository implements \Magento\Tax\Api\TaxClassRepositoryInterface
         $exception = new InputException();
 
         if (!\Zend_Validate::is(trim($taxClass->getClassName()), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_NAME]);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_NAME]));
         }
 
         $classType = $taxClass->getClassType();
         if (!\Zend_Validate::is(trim($classType), 'NotEmpty')) {
-            $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_TYPE]);
+            $exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => TaxClassInterface::KEY_TYPE]));
         } elseif ($classType !== TaxClassManagementInterface::TYPE_CUSTOMER
             && $classType !== TaxClassManagementInterface::TYPE_PRODUCT
         ) {
             $exception->addError(
-                InputException::INVALID_FIELD_VALUE,
-                ['fieldName' => TaxClassInterface::KEY_TYPE, 'value' => $classType]
+                __(
+                    InputException::INVALID_FIELD_VALUE,
+                    ['fieldName' => TaxClassInterface::KEY_TYPE, 'value' => $classType]
+                )
             );
         }
 
diff --git a/app/code/Magento/Tax/Model/TaxRuleRepository.php b/app/code/Magento/Tax/Model/TaxRuleRepository.php
index 7c7b1ed8f6cdd5ae6a0a6c3c8c232d56d8222e4a..d186c79b562aa9e44c5e1a9a2f83bae2ee866ea4 100644
--- a/app/code/Magento/Tax/Model/TaxRuleRepository.php
+++ b/app/code/Magento/Tax/Model/TaxRuleRepository.php
@@ -97,7 +97,7 @@ class TaxRuleRepository implements TaxRuleRepositoryInterface
         } catch (NoSuchEntityException $e) {
             throw $e;
         } catch (LocalizedException $e) {
-            throw new CouldNotSaveException($e->getMessage());
+            throw new CouldNotSaveException(__($e->getMessage()));
         }
         $this->taxRuleRegistry->registerTaxRule($rule);
         return $rule;
diff --git a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php
index ceeb3e67917ddb6ca33c9dee676cae6d485d08b5..80894cab62e2a22b77480e6f851031b07da9d144 100644
--- a/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php
+++ b/app/code/Magento/Tax/Test/Unit/Model/TaxClass/RepositoryTest.php
@@ -47,6 +47,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
      */
     protected $taxClassCollectionFactory;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -93,6 +96,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testDelete()
     {
         $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
@@ -103,6 +109,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
      * @expectedExceptionMessage Some Message
      */
@@ -113,10 +120,13 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->taxClassResourceMock
             ->expects($this->once())
             ->method('delete')
-            ->willThrowException(new CouldNotDeleteException('Some Message'));
+            ->willThrowException(new CouldNotDeleteException(__('Some Message')));
         $this->model->delete($taxClass);
     }
 
+    /**
+     * @return void
+     */
     public function testDeleteWithException()
     {
         $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
@@ -128,6 +138,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertFalse($this->model->delete($taxClass));
     }
 
+    /**
+     * @return void
+     */
     public function testGet()
     {
         $taxClass = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface');
@@ -140,7 +153,10 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals($taxClass, $this->model->get($classId));
     }
-    
+
+    /**
+     * @return void
+     */
     public function testDeleteById()
     {
         $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
@@ -158,6 +174,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertTrue($this->model->deleteById($classId));
     }
 
+    /**
+     * @return void
+     */
     public function testGetList()
     {
         $taxClassOne = $this->getMock('\Magento\Tax\Api\Data\TaxClassInterface');
@@ -195,6 +214,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($this->searchResultMock, $this->model->getList($searchCriteria));
     }
 
+    /**
+     * @return void
+     */
     public function testSave()
     {
         $taxClass = $this->getMock('\Magento\Tax\Model\ClassModel', [], [], '', false);
@@ -217,6 +239,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\InputException
      * @expectedExceptionMessage Updating classType is not allowed.
      */
@@ -232,6 +255,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\LocalizedException
      * @expectedExceptionMessage Something went wrong
      */
@@ -252,11 +276,12 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
             ->willReturn($originTaxClass);
 
         $this->taxClassResourceMock->expects($this->once())->method('save')->with($taxClass)
-            ->willThrowException(new LocalizedException("Something went wrong"));
+            ->willThrowException(new LocalizedException(__("Something went wrong")));
         $this->model->save($taxClass);
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception\LocalizedException
      * @expectedExceptionMessage A class with the same name already exists for ClassType PRODUCT.
      */
@@ -282,6 +307,8 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @param string $classType
+     * @return void
      * @dataProvider validateTaxClassDataProvider
      * @expectedException \Magento\Framework\Exception\InputException
      * @expectedExceptionMessage One or more input exceptions have occurred.
@@ -304,6 +331,9 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase
         $this->model->save($taxClass);
     }
 
+    /**
+     * @return array
+     */
     public function validateTaxClassDataProvider()
     {
         return [
diff --git a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php
index da444acf7499dec9c93f15305430356957ef47f7..37a6236bc3d37fd4d2873f7ce29559ed3ebf19ef 100644
--- a/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php
+++ b/app/code/Magento/Theme/Model/Design/Backend/Exceptions.php
@@ -61,7 +61,7 @@ class Exceptions extends ArraySerialized
             foreach (['search', 'value'] as $fieldName) {
                 if (!isset($row[$fieldName])) {
                     throw new \Magento\Framework\Exception\LocalizedException(
-                        __("Exception does not contain field '{$fieldName}'")
+                        __('Exception does not contain field \'%1\'', $fieldName)
                     );
                 }
             }
diff --git a/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php b/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php
index 795740b042a18109b34e15c2e74003c4968dc20b..a63656cadfe20cbe8c789c4406992bffdb7abb03 100644
--- a/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php
+++ b/app/code/Magento/Theme/Model/PageLayout/Config/Builder.php
@@ -13,9 +13,9 @@ namespace Magento\Theme\Model\PageLayout\Config;
 class Builder implements \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface
 {
     /**
-     * @var \Magento\Framework\ObjectManagerInterface
+     * @var \Magento\Framework\View\PageLayout\ConfigFactory
      */
-    protected $objectManager;
+    protected $configFactory;
 
     /**
      * @var \Magento\Framework\View\PageLayout\File\Collector\Aggregated
@@ -28,18 +28,19 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder
     protected $themeCollection;
 
     /**
-     * @param \Magento\Framework\ObjectManagerInterface $objectManager
+     * @param \Magento\Framework\View\PageLayout\ConfigFactory $configFactory
      * @param \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector
      * @param \Magento\Theme\Model\Resource\Theme\Collection $themeCollection
      */
     public function __construct(
-        \Magento\Framework\ObjectManagerInterface $objectManager,
+        \Magento\Framework\View\PageLayout\ConfigFactory $configFactory,
         \Magento\Framework\View\PageLayout\File\Collector\Aggregated $fileCollector,
         \Magento\Theme\Model\Resource\Theme\Collection $themeCollection
     ) {
-        $this->objectManager = $objectManager;
+        $this->configFactory = $configFactory;
         $this->fileCollector = $fileCollector;
         $this->themeCollection = $themeCollection;
+        $this->themeCollection->setItemObjectClass('Magento\Theme\Model\Theme\Data');
     }
 
     /**
@@ -47,10 +48,7 @@ class Builder implements \Magento\Framework\View\Model\PageLayout\Config\Builder
      */
     public function getPageLayoutsConfig()
     {
-        return $this->objectManager->create(
-            'Magento\Framework\View\PageLayout\Config',
-            ['configFiles' => $this->getConfigFiles()]
-        );
+        return $this->configFactory->create(['configFiles' => $this->getConfigFiles()]);
     }
 
     /**
diff --git a/app/code/Magento/Theme/Model/Resource/Design.php b/app/code/Magento/Theme/Model/Resource/Design.php
index 38782199dcad0b6ef86aef7fbc5f5f881b61bfd3..85a393429f1da5fb2ac48fac7024985ecc4c6b44 100644
--- a/app/code/Magento/Theme/Model/Resource/Design.php
+++ b/app/code/Magento/Theme/Model/Resource/Design.php
@@ -71,7 +71,9 @@ class Design extends \Magento\Framework\Model\Resource\Db\AbstractDb
             && (new \DateTime($object->getDateFrom()))->getTimestamp()
             > (new \DateTime($object->getDateTo()))->getTimestamp()
         ) {
-            throw new \Magento\Framework\Exception\LocalizedException(__('Start date cannot be greater than end date.'));
+            throw new \Magento\Framework\Exception\LocalizedException(
+                __('Start date cannot be greater than end date.')
+            );
         }
 
         $check = $this->_checkIntersection(
@@ -84,8 +86,8 @@ class Design extends \Magento\Framework\Model\Resource\Db\AbstractDb
         if ($check) {
             throw new \Magento\Framework\Exception\LocalizedException(
                 __(
-                    'Your design change for the specified store intersects with another one, please specify another
-                    date range.'
+                    'Your design change for the specified store intersects with another one, please specify another'
+                    . ' date range.'
                 )
             );
         }
diff --git a/app/code/Magento/Theme/Model/Theme.php b/app/code/Magento/Theme/Model/Theme.php
index 452a8b5d628857ff8eef59950a74adbfd665803a..a120ab45c9d94cda05efbc7dbae6edcc53748353 100644
--- a/app/code/Magento/Theme/Model/Theme.php
+++ b/app/code/Magento/Theme/Model/Theme.php
@@ -321,7 +321,7 @@ class Theme extends \Magento\Framework\Model\AbstractModel implements ThemeInter
     {
         if (!$this->_validator->validate($this)) {
             $messages = $this->_validator->getErrorMessages();
-            throw new \Magento\Framework\Exception\LocalizedException(implode(PHP_EOL, reset($messages)));
+            throw new \Magento\Framework\Exception\LocalizedException(__(implode(PHP_EOL, reset($messages))));
         }
         return $this;
     }
diff --git a/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php b/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php
new file mode 100755
index 0000000000000000000000000000000000000000..5d7df0ddef1b49bcff03747c1fbfafecfc904d5a
--- /dev/null
+++ b/app/code/Magento/Theme/Test/Unit/Model/PageLayout/Config/BuilderTest.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/**
+ * Test theme page layout config model
+ */
+namespace Magento\Theme\Test\Unit\Model\PageLayout\Config;
+
+class BuilderTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var Builder
+     */
+    protected $builder;
+
+    /**
+     * @var \Magento\Framework\View\PageLayout\ConfigFactory|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $configFactory;
+
+    /**
+     * @var \Magento\Framework\View\PageLayout\File\Collector\Aggregated|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $fileCollector;
+
+    /**
+     * @var \Magento\Theme\Model\Resource\Theme\Collection|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $themeCollection;
+
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
+    protected function setUp()
+    {
+        $this->configFactory = $this->getMockBuilder('Magento\Framework\View\PageLayout\ConfigFactory')
+            ->disableOriginalConstructor()
+            ->setMethods(['create'])
+            ->getMock();
+
+        $this->fileCollector = $this->getMockBuilder('Magento\Framework\View\PageLayout\File\Collector\Aggregated')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->themeCollection = $this->getMockBuilder('Magento\Theme\Model\Resource\Theme\Collection')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->themeCollection->expects($this->once())
+            ->method('setItemObjectClass')
+            ->with('Magento\Theme\Model\Theme\Data')
+            ->willReturnSelf();
+
+        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->builder = $helper->getObject(
+            'Magento\Theme\Model\PageLayout\Config\Builder',
+            [
+                'configFactory' => $this->configFactory,
+                'fileCollector' => $this->fileCollector,
+                'themeCollection' => $this->themeCollection
+            ]
+        );
+    }
+
+    /**
+     * Test get page layouts config
+     *
+     * @return void
+     */
+    public function testGetPageLayoutsConfig()
+    {
+        $files1 = ['content layouts_1.xml', 'content layouts_2.xml'];
+        $files2 = ['content layouts_3.xml', 'content layouts_4.xml'];
+
+        $theme1 = $this->getMockBuilder('Magento\Theme\Model\Theme\Data')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $theme2 = $this->getMockBuilder('Magento\Theme\Model\Theme\Data')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->themeCollection->expects($this->any())
+            ->method('loadRegisteredThemes')
+            ->willReturn([$theme1, $theme2]);
+
+        $this->fileCollector->expects($this->exactly(2))
+            ->method('getFilesContent')
+            ->willReturnMap(
+                [
+                    [$theme1, 'layouts.xml', $files1],
+                    [$theme2, 'layouts.xml', $files2]
+                ]
+            );
+
+        $config = $this->getMockBuilder('Magento\Framework\View\PageLayout\Config')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->configFactory->expects($this->once())
+            ->method('create')
+            ->with(['configFiles' => array_merge($files1, $files2)])
+            ->willReturn($config);
+
+        $this->assertSame($config, $this->builder->getPageLayoutsConfig());
+    }
+}
diff --git a/app/code/Magento/Ui/view/base/web/js/form.js b/app/code/Magento/Ui/view/base/web/js/form.js
index 2fec472c353c64f7fdec3ecfbcbbfd470ee7b7d2..ef54b43da90399b6894c697e2f49cb46795af55a 100644
--- a/app/code/Magento/Ui/view/base/web/js/form.js
+++ b/app/code/Magento/Ui/view/base/web/js/form.js
@@ -3,20 +3,19 @@
  * See COPYING.txt for license details.
  */
 define([
+    'jquery',
     'underscore',
     'Magento_Ui/js/form/component',
     'Magento_Ui/js/lib/spinner',
     './form/adapter'
-], function (_, Component, loader, adapter) {
+], function ($, _, Component, loader, adapter) {
     'use strict';
 
-    function collectData(selector){
-        var items = document.querySelectorAll(selector),
+    function collectData(selector) {
+        var data = $(selector).serializeArray(),
             result = {};
 
-        items = Array.prototype.slice.call(items);
-
-        items.forEach(function(item){
+        data.forEach(function (item) {
             result[item.name] = item.value;
         });
 
diff --git a/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php
index d293ddb124bd606bd15e2accbda26c96cbf296f6..185241b3f27378f0b9e909f4a85bb419cd95d65d 100644
--- a/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php
+++ b/app/code/Magento/UrlRewrite/Helper/UrlRewrite.php
@@ -53,7 +53,7 @@ class UrlRewrite extends \Magento\Framework\App\Helper\AbstractHelper
         try {
             $this->_validateRequestPath($requestPath);
         } catch (\Exception $e) {
-            throw new \Magento\Framework\Exception\LocalizedException($e->getMessage());
+            throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
         }
         return true;
     }
diff --git a/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php b/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php
index 6160524ed20b1d894270556276ef4a8135a5de8b..834e5e19b0139bc183c8c872fd0b042b179e3609 100644
--- a/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php
+++ b/app/code/Magento/User/Controller/Adminhtml/Auth/ResetPasswordPost.php
@@ -45,7 +45,7 @@ class ResetPasswordPost extends \Magento\User\Controller\Adminhtml\Auth
             $this->getResponse()->setRedirect(
                 $this->_objectManager->get('Magento\Backend\Helper\Data')->getHomePageUrl()
             );
-        } catch (\Magento\Framework\Validator\ValidatorException $exception) {
+        } catch (\Magento\Framework\Validator\Exception $exception) {
             $this->messageManager->addMessages($exception->getMessages());
             $this->_redirect(
                 'adminhtml/auth/resetpassword',
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Save.php b/app/code/Magento/User/Controller/Adminhtml/User/Save.php
index f472c97e0c5a6e48c0b1ac6c721b20038698f271..204b188822dbf8935ba57ccdacd7d8438deaf8be 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Save.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Save.php
@@ -62,7 +62,7 @@ class Save extends \Magento\User\Controller\Adminhtml\User
             $this->messageManager->addSuccess(__('You saved the user.'));
             $this->_getSession()->setUserData(false);
             $this->_redirect('adminhtml/*/');
-        } catch (\Magento\Framework\Validator\ValidatorException $e) {
+        } catch (\Magento\Framework\Validator\Exception $e) {
             $messages = $e->getMessages();
             $this->messageManager->addMessages($messages);
             $this->redirectToEdit($model, $data);
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Validate.php b/app/code/Magento/User/Controller/Adminhtml/User/Validate.php
index 847cae30712a88d7326417739f1ba732e688e2f0..bf4cddb3a7c0639b1338e41fb797631a9a8599be 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Validate.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Validate.php
@@ -25,7 +25,7 @@ class Validate extends \Magento\User\Controller\Adminhtml\User
             $model = $this->_userFactory->create()->load($userId);
             $model->setData($this->_getAdminUserData($data));
             $errors = $model->validate();
-        } catch (\Magento\Framework\Validator\ValidatorException $exception) {
+        } catch (\Magento\Framework\Validator\Exception $exception) {
             /* @var $error Error */
             foreach ($exception->getMessages(\Magento\Framework\Message\MessageInterface::TYPE_ERROR) as $error) {
                 $errors[] = $error->getText();
diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php
index 0974dc185b99bbc55d0449db2b8a873307ab2690..594ebf3aa0c37468e8304f461da415eb992169e6 100644
--- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php
+++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable.php
@@ -37,7 +37,7 @@ class Variable extends Action
     protected $resultPageFactory;
 
     /**
-     * @var \Magento\Framework\Controller\Result\JSONFactory
+     * @var \Magento\Framework\Controller\Result\JsonFactory
      */
     protected $resultJsonFactory;
 
@@ -51,7 +51,7 @@ class Variable extends Action
      * @param \Magento\Framework\Registry $coreRegistry
      * @param \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory
      * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
-     * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory
+     * @param \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory
      * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
      * @param \Magento\Framework\View\LayoutFactory $layoutFactory
      */
@@ -60,7 +60,7 @@ class Variable extends Action
         \Magento\Framework\Registry $coreRegistry,
         \Magento\Backend\Model\View\Result\RedirectFactory $resultRedirectFactory,
         \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
-        \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory,
+        \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory,
         \Magento\Framework\View\Result\PageFactory $resultPageFactory,
         \Magento\Framework\View\LayoutFactory $layoutFactory
     ) {
diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php
index 41f4738f0a56c7ad1474d8c13797b40b4638ad57..684330532414b51231cf74f811403776001f0a0f 100644
--- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php
+++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Validate.php
@@ -11,7 +11,7 @@ class Validate extends \Magento\Variable\Controller\Adminhtml\System\Variable
     /**
      * Validate Action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -26,7 +26,7 @@ class Validate extends \Magento\Variable\Controller\Adminhtml\System\Variable
             $response->setError(true);
             $response->setHtmlMessage($layout->getMessagesBlock()->getGroupedHtml());
         }
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData($response->toArray());
     }
diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php
index 4d040feb6a6b4f3e9df1a4d7ef44f1fb711c93b2..04b1514cfab7f3b8b6ce4b19ac4f0b7e8da517f9 100644
--- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php
+++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/WysiwygPlugin.php
@@ -11,7 +11,7 @@ class WysiwygPlugin extends \Magento\Variable\Controller\Adminhtml\System\Variab
     /**
      * WYSIWYG Plugin Action
      *
-     * @return \Magento\Framework\Controller\Result\JSON
+     * @return \Magento\Framework\Controller\Result\Json
      */
     public function execute()
     {
@@ -22,7 +22,7 @@ class WysiwygPlugin extends \Magento\Variable\Controller\Adminhtml\System\Variab
         )->toOptionArray(
             true
         );
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = $this->resultJsonFactory->create();
         return $resultJson->setData([$storeContactVariabls, $customVariables]);
     }
diff --git a/app/code/Magento/Webapi/Controller/Rest.php b/app/code/Magento/Webapi/Controller/Rest.php
index 43383e07afdc3d9a378587832d4e3340f6f368a5..dc68d6cd3b67d976e67993da41db16ae8d7463a5 100644
--- a/app/code/Magento/Webapi/Controller/Rest.php
+++ b/app/code/Magento/Webapi/Controller/Rest.php
@@ -218,7 +218,9 @@ class Rest implements \Magento\Framework\App\FrontControllerInterface
         $route = $this->getCurrentRoute();
         if (!$this->isAllowed($route->getAclResources())) {
             $params = ['resources' => implode(', ', $route->getAclResources())];
-            throw new AuthorizationException(AuthorizationException::NOT_AUTHORIZED, $params);
+            throw new AuthorizationException(
+                __(AuthorizationException::NOT_AUTHORIZED, $params)
+            );
         }
     }
 
diff --git a/app/code/Magento/Webapi/Controller/Soap.php b/app/code/Magento/Webapi/Controller/Soap.php
index f5b47bf257e1c3b933706c1e8c19ec51eff6abb9..63d9968b495008e38c8644e75599745124885079 100644
--- a/app/code/Magento/Webapi/Controller/Soap.php
+++ b/app/code/Magento/Webapi/Controller/Soap.php
@@ -155,9 +155,9 @@ class Soap implements \Magento\Framework\App\FrontControllerInterface
             if (isset($token[1]) && is_string($token[1])) {
                 return $token[1];
             }
-            throw new AuthorizationException('Authentication header format is invalid.');
+            throw new AuthorizationException(__('Authentication header format is invalid.'));
         }
-        throw new AuthorizationException('Authentication header is absent.');
+        throw new AuthorizationException(__('Authentication header is absent.'));
     }
 
     /**
diff --git a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
index cafdaa8927b9322b72a04cb8055d36cb676b9fa8..862b8278d9a942ab4c23edc36034ed37c5aaff28 100644
--- a/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
+++ b/app/code/Magento/Webapi/Controller/Soap/Request/Handler.php
@@ -109,8 +109,10 @@ class Handler
 
         if (!$isAllowed) {
             throw new AuthorizationException(
-                AuthorizationException::NOT_AUTHORIZED,
-                ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])]
+                __(
+                    AuthorizationException::NOT_AUTHORIZED,
+                    ['resources' => implode(', ', $serviceMethodInfo[SoapConfig::KEY_ACL_RESOURCES])]
+                )
             );
         }
         $service = $this->_objectManager->get($serviceClass);
diff --git a/app/code/Magento/Webapi/Model/Soap/Fault.php b/app/code/Magento/Webapi/Model/Soap/Fault.php
index 940fc85e4446b07d9e36fc3942ae4b08fbe63e6b..c48d6fb55bc1e7f8c82d3301094865bfeae89a2a 100644
--- a/app/code/Magento/Webapi/Model/Soap/Fault.php
+++ b/app/code/Magento/Webapi/Model/Soap/Fault.php
@@ -301,7 +301,6 @@ FAULT_MESSAGE;
         if (!is_array($parameters)) {
             return $result;
         }
-
         $paramsXml = '';
         foreach ($parameters as $parameterName => $parameterValue) {
             if (is_string($parameterName) && (is_string($parameterValue) || is_numeric($parameterValue))) {
diff --git a/app/code/Magento/Wishlist/Controller/Index/Add.php b/app/code/Magento/Wishlist/Controller/Index/Add.php
index 997590a667ded0dfeea35e441ed5d1759b45f7e4..d957719932a2bdac2c787d9f46b72e0a7b66bb72 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Add.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Add.php
@@ -96,7 +96,7 @@ class Add extends Action\Action implements IndexInterface
 
             $result = $wishlist->addNewItem($product, $buyRequest);
             if (is_string($result)) {
-                throw new \Magento\Framework\Exception\LocalizedException($result);
+                throw new \Magento\Framework\Exception\LocalizedException(__($result));
             }
             $wishlist->save();
 
diff --git a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php
index aceb8318505b0852b4dfc0ced5b3d381e17e24df..2bf785573e273813fe50c286b3b40f69cada4ab8 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Fromcart.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Fromcart.php
@@ -51,7 +51,9 @@ class Fromcart extends Action\Action implements IndexInterface
         try {
             $item = $cart->getQuote()->getItemById($itemId);
             if (!$item) {
-                throw new \Magento\Framework\Exception\LocalizedException(__("The requested cart item doesn't exist."));
+                throw new \Magento\Framework\Exception\LocalizedException(
+                    __('The requested cart item doesn\'t exist.')
+                );
             }
 
             $productId = $item->getProductId();
diff --git a/app/code/Magento/Wishlist/Controller/WishlistProvider.php b/app/code/Magento/Wishlist/Controller/WishlistProvider.php
index 20daf96c7b1011fbca8cd96ed2836ac369b38919..117254895ca23f8e4cf1f9c4f5edd44bced00b48 100644
--- a/app/code/Magento/Wishlist/Controller/WishlistProvider.php
+++ b/app/code/Magento/Wishlist/Controller/WishlistProvider.php
@@ -81,7 +81,7 @@ class WishlistProvider implements WishlistProviderInterface
 
             if (!$wishlist->getId() || $wishlist->getCustomerId() != $customerId) {
                 throw new \Magento\Framework\Exception\NoSuchEntityException(
-                    __("The requested wish list doesn't exist.")
+                    __('The requested wish list doesn\'t exist.')
                 );
             }
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
diff --git a/app/code/Magento/Wishlist/Model/Item.php b/app/code/Magento/Wishlist/Model/Item.php
index e64bead64c92ec1c49f718e8a14a746ccbab8c4b..89c11e487da39cc28c8ea14e964237e4baa5203b 100644
--- a/app/code/Magento/Wishlist/Model/Item.php
+++ b/app/code/Magento/Wishlist/Model/Item.php
@@ -381,7 +381,7 @@ class Item extends AbstractModel implements ItemInterface
             try {
                 $product = $this->productRepository->getById($this->getProductId(), false, $this->getStoreId());
             } catch (NoSuchEntityException $e) {
-                throw new \Magento\Framework\Exception\LocalizedException(__('Cannot specify product.'), [], $e);
+                throw new \Magento\Framework\Exception\LocalizedException(__('Cannot specify product.'), $e);
             }
             $this->setData('product', $product);
         }
diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
old mode 100644
new mode 100755
index f971e7af207e8780a89b6743121875a2a93b1ef2..9fddb7383a3034e51fcf973eb797f4638189083a
--- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
@@ -71,6 +71,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
      */
     protected $eventManager;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     protected function setUp()
     {
         $this->productRepository = $this->getMock('Magento\Catalog\Model\ProductRepository', [], [], '', false);
@@ -87,6 +92,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         $this->eventManager = $this->getMock('Magento\Framework\Event\Manager', [], [], '', false);
     }
 
+    /**
+     * TearDown method
+     *
+     * @return void
+     */
     public function tearDown()
     {
         unset(
@@ -104,6 +114,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Prepare context
+     *
+     * @return void
+     */
     public function prepareContext()
     {
         $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', [], [], '', false);
@@ -146,6 +161,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
             ->willReturn($this->messageManager);
     }
 
+    /**
+     * Get controller
+     *
+     * @return \Magento\Wishlist\Controller\Index\UpdateItemOptions
+     */
     protected function getController()
     {
         $this->prepareContext();
@@ -157,6 +177,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * Test execute without product id
+     *
+     * @return void
+     */
     public function testExecuteWithoutProductId()
     {
         $this->request
@@ -174,6 +199,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         $this->getController()->execute();
     }
 
+    /**
+     * Test execute without product
+     *
+     * @return void
+     */
     public function testExecuteWithoutProduct()
     {
         $this->request
@@ -203,6 +233,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         $this->getController()->execute();
     }
 
+    /**
+     * Test execute without wish list
+     *
+     * @return void
+     */
     public function testExecuteWithoutWishList()
     {
         $product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false);
@@ -269,6 +304,9 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * Test execute add success exception
+     *
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testExecuteAddSuccessException()
@@ -372,7 +410,7 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
             ->expects($this->once())
             ->method('addSuccess')
             ->with('Test name has been updated in your wish list.', null)
-            ->willThrowException(new \Magento\Framework\Exception\LocalizedException('error-message'));
+            ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('error-message')));
         $this->messageManager
             ->expects($this->once())
             ->method('addError')
@@ -388,6 +426,9 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase
         $this->getController()->execute();
     }
     /**
+     * Test execute add success critical exception
+     *
+     * @return void
      * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
      */
     public function testExecuteAddSuccessCriticalException()
diff --git a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
index ffbdfe4c5fbe3774f1d46d1bce60f63adc317085..733448e77319ba27a2481791aac0217e6846456f 100644
--- a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
+++ b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
@@ -11,7 +11,7 @@ define([
     
     $.widget('mage.addToWishlist', {
         options: {
-            bundleInfo: '[id^=bundle-option-]:checked',
+            bundleInfo: 'div.control [name^=bundle_option]:not([name*=qty])',
             configurableInfo: '.super-attribute-select',
             groupedInfo: '#super-product-table input',
             downloadableInfo: '#downloadable-links-list input',
@@ -32,18 +32,55 @@ define([
             this._on(events);
         },
         _updateWishlistData: function(event) {
-            var dataToAdd = {};
+            var dataToAdd = {},
+                dataOrigin = {};
+            var self = this;
             $(event.handleObj.selector).each(function(index, element){
-                dataToAdd[$(element).attr('name')] = $(element).val();
+                dataOrigin = $.extend({}, dataOrigin, self._getElementData(element, 1));
+                if ($(element).is(':checked') || $(element).find(':checked').length) {
+                    dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
+                }
             });
-            var self = this;
             $('[data-action="add-to-wishlist"]').each(function(index, element) {
                 var params = $(element).data('post');
                 if (!params)
                     params = {};
+                self._removeExcessiveData(params, dataOrigin, dataToAdd);
                 params.data = $.extend({}, params.data, dataToAdd, {'qty': $(self.options.qtyInfo).val()});
                 $(element).data('post', params);
             });
+            event.stopPropagation();
+        },
+        _arrayDiffByKeys: function(array1, array2) {
+            var result = {};
+            $.each(array1, function(key, value) {
+                if (!array2[key])
+                    result[key] = value;
+            });
+            return result;
+        },
+        _getElementData: function(element, origin) {
+            var data = {},
+                elementName = $(element).attr('name'),
+                elementValue = $(element).val();
+            if (origin && $(element).is('select')) {
+                elementValue = $(element).find('option');
+            }
+            if ($(element).is('select[multiple]')) {
+                $.each(elementValue, function(key, option) {
+                    var value = origin ? option.value : option;
+                    data[elementName + '[' + value + ']'] = value;
+                });
+            } else {
+                data[elementName] = elementValue;
+            }
+            return data;
+        },
+        _removeExcessiveData: function(params, dataOrigin, dataToAdd) {
+            var dataToRemove = this._arrayDiffByKeys(dataOrigin, dataToAdd);
+            $.each(dataToRemove, function(key, value) {
+                delete params.data[key];
+            });
         }
     });
     
diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php
index e1f4b6a99564875820989179cb5959df14e9bbc1..9ef7c6bda142674f4ebdbb87bef10d5bc720109d 100644
--- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php
+++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/Error.php
@@ -42,7 +42,12 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface
      */
     public function resourceNotFoundException()
     {
-        throw new NoSuchEntityException('Resource with ID "%resource_id" not found.', ['resource_id' => 'resourceY']);
+        throw new NoSuchEntityException(
+            __(
+                'Resource with ID "%1" not found.',
+                'resourceY'
+            )
+        );
     }
 
     /**
@@ -50,19 +55,7 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface
      */
     public function serviceException()
     {
-        throw new LocalizedException('Generic service exception %param', ['param' => 3456]);
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function parameterizedServiceException($parameters)
-    {
-        $details = [];
-        foreach ($parameters as $parameter) {
-            $details[$parameter->getName()] = $parameter->getValue();
-        }
-        throw new LocalizedException('Parameterized service exception', $details);
+        throw new LocalizedException(__('Generic service exception %1', 3456));
     }
 
     /**
@@ -70,9 +63,7 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface
      */
     public function authorizationException()
     {
-        throw new AuthorizationException('Consumer is not authorized to access %resources', [
-            'resources'   => 'resourceN'
-        ]);
+        throw new AuthorizationException(__('Consumer is not authorized to access %1', 'resourceN'));
     }
 
     /**
@@ -112,8 +103,10 @@ class Error implements \Magento\TestModule3\Service\V1\ErrorInterface
         if ($wrappedErrorParameters) {
             foreach ($wrappedErrorParameters as $error) {
                 $exception->addError(
-                    InputException::INVALID_FIELD_VALUE,
-                    ['fieldName' => $error->getFieldName(), 'value' => $error->getValue()]
+                    __(
+                        InputException::INVALID_FIELD_VALUE,
+                        ['fieldName' => $error->getFieldName(), 'value' => $error->getValue()]
+                    )
                 );
             }
         }
diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php
index ee6737049398ddc55cfb0ac13419d0d8cd63814e..b4539f7a2b3b8ee7f45cc8f279f9c2f7a448dffe 100644
--- a/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php
+++ b/dev/tests/api-functional/_files/Magento/TestModule3/Service/V1/ErrorInterface.php
@@ -7,8 +7,6 @@
  */
 namespace Magento\TestModule3\Service\V1;
 
-use Magento\TestModule3\Service\V1\Entity\Parameter;
-
 interface ErrorInterface
 {
     /**
@@ -26,12 +24,6 @@ interface ErrorInterface
      */
     public function serviceException();
 
-    /**
-     * @param \Magento\TestModule3\Service\V1\Entity\Parameter[] $parameters
-     * @return int Status
-     */
-    public function parameterizedServiceException($parameters);
-
     /**
      * @return int Status
      */
diff --git a/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml b/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml
index 8a27786d39b4d7d119e5b93633f8ed21e6e7f402..0a5fa58cfd31f82aa44c77ddd3c5c60d2e24176d 100644
--- a/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml
+++ b/dev/tests/api-functional/_files/Magento/TestModule3/etc/webapi.xml
@@ -24,12 +24,6 @@
             <resource ref="Magento_TestModule3::resource1" />
         </resources>
     </route>
-    <route method="POST" url="/V1/errortest/parameterizedserviceexception">
-        <service class="Magento\TestModule3\Service\V1\ErrorInterface" method="parameterizedServiceException" />
-        <resources>
-            <resource ref="Magento_TestModule3::resource1" />
-        </resources>
-    </route>
     <route method="GET" url="/V1/errortest/unauthorized">
         <service class="Magento\TestModule3\Service\V1\ErrorInterface" method="authorizationException" />
         <resources>
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php
index 4ea45309be3c9c937a6c15bbc2e5d7eccf50fc13..36d3dc65d184cfd95e09d4d3e97186b4d4770f04 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php
@@ -59,7 +59,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
         $payload = $this->getAttributeData();
         $payload['attributeSetId'] = -1;
 
-        $expectedMessage = 'AttributeSet with id "' . $payload['attributeSetId'] . '" does not exist.';
+        $expectedMessage = 'AttributeSet with id "%1" does not exist.';
 
         try {
             $this->_webApiCall($this->getAssignServiceInfo(), $payload);
@@ -73,6 +73,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
         } catch (\Exception $e) {
             $errorObj = $this->processRestExceptionResult($e);
             $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$payload['attributeSetId']], $errorObj['parameters']);
             $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode());
         }
     }
@@ -81,7 +82,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
     {
         $payload = $this->getAttributeData();
         $payload['attributeGroupId'] = -1;
-        $expectedMessage = 'Group with id "' . $payload['attributeGroupId'] . '" does not exist.';
+        $expectedMessage = 'Group with id "%1" does not exist.';
 
         try {
             $this->_webApiCall($this->getAssignServiceInfo(), $payload);
@@ -95,6 +96,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
         } catch (\Exception $e) {
             $errorObj = $this->processRestExceptionResult($e);
             $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$payload['attributeGroupId']], $errorObj['parameters']);
             $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode());
         }
     }
@@ -103,7 +105,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
     {
         $payload = $this->getAttributeData();
         $payload['attributeCode'] = 'badCode';
-        $expectedMessage = 'Attribute with attributeCode "' . $payload['attributeCode'] . '" does not exist.';
+        $expectedMessage = 'Attribute with attributeCode "%1" does not exist.';
 
         try {
             $this->_webApiCall($this->getAssignServiceInfo(), $payload);
@@ -117,6 +119,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web
         } catch (\Exception $e) {
             $errorObj = $this->processRestExceptionResult($e);
             $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$payload['attributeCode']], $errorObj['parameters']);
             $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode());
         }
     }
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php
index 0b905f432815a215f39abd6cb709de72a9fbcbe9..7bb1fccd68818c9804f508c9c9f4a445527c9257 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeRepositoryTest.php
@@ -159,7 +159,7 @@ class ProductAttributeRepositoryTest extends \Magento\TestFramework\TestCase\Web
     public function testDeleteNoSuchEntityException()
     {
         $attributeCode = 'some_test_code';
-        $expectedMessage = 'Attribute with attributeCode "' . $attributeCode . '" does not exist.';
+        $expectedMessage = 'Attribute with attributeCode "%1" does not exist.';
 
         $serviceInfo = [
             'rest' => [
@@ -185,6 +185,7 @@ class ProductAttributeRepositoryTest extends \Magento\TestFramework\TestCase\Web
         } catch (\Exception $e) {
             $errorObj = $this->processRestExceptionResult($e);
             $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$attributeCode], $errorObj['parameters']);
             $this->assertEquals(HTTPExceptionCodes::HTTP_NOT_FOUND, $e->getCode());
         }
     }
diff --git a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php
index a14d5e9bd009e50963660a04d82769531ced3c1b..4551eaa3e45e2d713487938cf485344c5ff10b5c 100644
--- a/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/ConfigurableProduct/Api/OptionRepositoryTest.php
@@ -109,14 +109,25 @@ class OptionRepositoryTest extends \Magento\TestFramework\TestCase\WebapiAbstrac
 
     /**
      * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
-     * @expectedException \Exception
-     * @expectedExceptionMessage Requested option doesn't exist: -42
      */
     public function testGetUndefinedOption()
     {
+        $expectedMessage = 'Requested option doesn\'t exist: %1';
         $productSku = 'configurable';
         $attributeId = -42;
-        $this->get($productSku, $attributeId);
+        try {
+            $this->get($productSku, $attributeId);
+        } catch (\SoapFault $e) {
+            $this->assertContains(
+                $expectedMessage,
+                $e->getMessage(),
+                'SoapFault does not contain expected message.'
+            );
+        } catch (\Exception $e) {
+            $errorObj = $this->processRestExceptionResult($e);
+            $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$attributeId], $errorObj['parameters']);
+        }
     }
 
     /**
diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
index d2a39785a85ef845de66f72b902ff4411495e46a..998e7414785ea26104ca4bd3e20a68ccc0576220 100644
--- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php
@@ -147,8 +147,10 @@ class AccountManagementTest extends WebapiAbstract
             if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
                 $expectedException = new InputException();
                 $expectedException->addError(
-                    InputException::INVALID_FIELD_VALUE,
-                    ['fieldName' => 'email', 'value' => $invalidEmail]
+                    __(
+                        InputException::INVALID_FIELD_VALUE,
+                        ['fieldName' => 'email', 'value' => $invalidEmail]
+                    )
                 );
                 $this->assertInstanceOf('SoapFault', $e);
                 $this->checkSoapFault(
diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php
index 270b433a6a7084201221b224560ae32ca68dfc45..6217cc99b088f063669901fdc5e1d492794e1e2c 100644
--- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/ShippingMethodManagementTest.php
@@ -68,22 +68,30 @@ class ShippingMethodManagementTest extends WebapiAbstract
      */
     public function testSetMethodWrongMethod()
     {
+        $expectedMessage = 'Carrier with such method not found: %1, %2';
         $this->quote->load('test_order_1', 'reserved_order_id');
         $serviceInfo = $this->getServiceInfo();
+        $carrierCode = 'flatrate';
+        $methodCode = 'wrongMethod';
 
         $requestData = [
             'cartId' => $this->quote->getId(),
-            'carrierCode' => 'flatrate',
-            'methodCode' => 'wrongMethod',
+            'carrierCode' => $carrierCode,
+            'methodCode' => $methodCode,
         ];
         try {
             $this->_webApiCall($serviceInfo, $requestData);
         } catch (\SoapFault $e) {
-            $message = $e->getMessage();
+            $this->assertContains(
+                $expectedMessage,
+                $e->getMessage(),
+                'SoapFault does not contain expected message.'
+            );
         } catch (\Exception $e) {
-            $message = json_decode($e->getMessage())->message;
+            $errorObj = $this->processRestExceptionResult($e);
+            $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals([$carrierCode, $methodCode], $errorObj['parameters']);
         }
-        $this->assertEquals('Carrier with such method not found: flatrate, wrongMethod', $message);
     }
 
     /**
diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php
index 6bd1fb20cf5410ba7b209334bdf9437e02f376f4..df2cf377a532c3e4c79a9c1ec59ac58663e8c4f8 100644
--- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRateRepositoryTest.php
@@ -14,6 +14,9 @@ use Magento\Tax\Api\Data\TaxRateInterface as TaxRate;
 use Magento\TestFramework\Helper\Bootstrap;
 use Magento\TestFramework\TestCase\WebapiAbstract;
 
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
 class TaxRateRepositoryTest extends WebapiAbstract
 {
     const SERVICE_NAME = "taxTaxRateRepositoryV1";
@@ -97,6 +100,7 @@ class TaxRateRepositoryTest extends WebapiAbstract
 
     public function testCreateTaxRateExistingCode()
     {
+        $expectedMessage = '%1 already exists.';
         $data = [
             'tax_rate' => [
                 'tax_country_id' => 'US',
@@ -121,14 +125,16 @@ class TaxRateRepositoryTest extends WebapiAbstract
         try {
             $this->_webApiCall($serviceInfo, $data);
             $this->fail('Expected exception was not raised');
-        } catch (\Exception $e) {
-            $expectedMessage = 'Code already exists.';
-
+        } catch (\SoapFault $e) {
             $this->assertContains(
                 $expectedMessage,
                 $e->getMessage(),
-                "Exception does not contain expected message."
+                'SoapFault does not contain expected message.'
             );
+        } catch (\Exception $e) {
+            $errorObj = $this->processRestExceptionResult($e);
+            $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals(['Code'], $errorObj['parameters']);
         }
     }
 
diff --git a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php
index 7d3c6d7a1c2940b6e3ebb26653efdf3d1bc1fabc..4bef167f0e8ea063f601dc495ab4bd44a63de3b9 100644
--- a/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Tax/Api/TaxRuleRepositoryInterfaceTest.php
@@ -178,6 +178,7 @@ class TaxRuleRepositoryInterfaceTest extends WebapiAbstract
 
     public function testCreateTaxRuleExistingCode()
     {
+        $expectedMessage = '%1 already exists.';
         $requestData = [
             'rule' => [
                 'code' => 'Test Rule ' . microtime(),
@@ -205,13 +206,16 @@ class TaxRuleRepositoryInterfaceTest extends WebapiAbstract
         try {
             $this->_webApiCall($serviceInfo, $requestData);
             $this->fail('Expected exception was not raised');
-        } catch (\Exception $e) {
-            $expectedMessage = 'Code already exists.';
+        } catch (\SoapFault $e) {
             $this->assertContains(
                 $expectedMessage,
                 $e->getMessage(),
-                "Exception does not contain expected message."
+                'SoapFault does not contain expected message.'
             );
+        } catch (\Exception $e) {
+            $errorObj = $this->processRestExceptionResult($e);
+            $this->assertEquals($expectedMessage, $errorObj['message']);
+            $this->assertEquals(['Code'], $errorObj['parameters']);
         }
 
         // Clean up the new tax rule so it won't affect other tests
diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php
index 08ed84696127726a99fe2cc2b9a8d5da2eaaf425..41d6e8a2914deb9a863b42d2634d0c9aab934324 100644
--- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/RestErrorHandlingTest.php
@@ -52,9 +52,9 @@ class RestErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra
         // \Magento\Framework\Api\ResourceNotFoundException
         $this->_errorTest(
             $serviceInfo,
-            ['resource_id' => 'resourceY'],
+            ['resourceY'],
             WebapiException::HTTP_NOT_FOUND,
-            'Resource with ID "%resource_id" not found.'
+            'Resource with ID "%1" not found.'
         );
     }
 
@@ -72,8 +72,8 @@ class RestErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra
             $serviceInfo,
             [],
             WebapiException::HTTP_UNAUTHORIZED,
-            'Consumer is not authorized to access %resources',
-            ['resources' => 'resourceN']
+            'Consumer is not authorized to access %1',
+            ['resourceN']
         );
     }
 
diff --git a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php
index 648173c6e6b5c50feed6267a030e7f5e014b6c3c..a7dadda3c5b6e67ba77cd94a0ebcdd339a4ec692 100644
--- a/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Webapi/Routing/SoapErrorHandlingTest.php
@@ -105,8 +105,10 @@ class SoapErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra
         ];
 
         $expectedException = new AuthorizationException(
-            AuthorizationException::NOT_AUTHORIZED,
-            ['resources' => 'Magento_TestModule3::resource1, Magento_TestModule3::resource2']
+            __(
+                AuthorizationException::NOT_AUTHORIZED,
+                ['resources' => 'Magento_TestModule3::resource1, Magento_TestModule3::resource2']
+            )
         );
 
         try {
@@ -133,7 +135,9 @@ class SoapErrorHandlingTest extends \Magento\TestFramework\TestCase\WebapiAbstra
 
         $expectedException = new \Magento\Framework\Exception\InputException();
         foreach ($parameters as $error) {
-            $expectedException->addError(\Magento\Framework\Exception\InputException::INVALID_FIELD_VALUE, $error);
+            $expectedException->addError(
+                __(\Magento\Framework\Exception\InputException::INVALID_FIELD_VALUE, $error)
+            );
         }
 
         $arguments = [
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
index 7f2caa27ef07634ab7d1e064a10daf54f17db648..f9e5c43acb695f35c3eca409b1d0c12b6b0bcf0d 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
@@ -39,14 +39,12 @@
     </variation>
     <variation name="AddProductToWishlistEntityTestVariation6" firstConstraint="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage" method="test">
       <data name="product" xsi:type="string">bundleProduct::bundle_dynamic_product</data>
-      <data name="issue" xsi:type="string">Bug: MAGETWO-33952</data>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage" next="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist"/>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist" next="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInCustomerBackendWishlist" prev="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage"/>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInCustomerBackendWishlist" prev="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist"/>
     </variation>
     <variation name="AddProductToWishlistEntityTestVariation7" firstConstraint="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage" method="test">
       <data name="product" xsi:type="string">bundleProduct::bundle_fixed_product</data>
-      <data name="issue" xsi:type="string">Bug: MAGETWO-33952</data>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage" next="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist"/>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist" next="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInCustomerBackendWishlist" prev="Magento\Wishlist\Test\Constraint\AssertAddProductToWishlistSuccessMessage"/>
       <constraint name="Magento\Wishlist\Test\Constraint\AssertProductIsPresentInCustomerBackendWishlist" prev="Magento\Wishlist\Test\Constraint\AssertProductDetailsInWishlist"/>
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php
index d39b040df295d85c733c3a86613ac5860b33da06..eb8ec06003ac4f24253b991563579c4818fe3335 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php
@@ -49,7 +49,7 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Framework\Validator\ValidatorException
+     * @expectedException \Magento\Framework\Validator\Exception
      * @return void
      */
     public function testRunValidationException()
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index a267e9b299762a901b22dc3fc89715a6c0a6e637..63af5eeb61344361524d256fe3cf6f3fa627fc52 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -152,7 +152,7 @@ class AccountTest extends \Magento\TestFramework\TestCase\AbstractController
             ->setPostValue('create_address', true);
 
         $this->dispatch('customer/account/createPost');
-        $this->assertRedirect($this->stringContains('customer/account/index/'));
+        $this->assertRedirect($this->stringContains('customer/account/'));
         $this->assertSessionMessages(
             $this->equalTo(['Thank you for registering with Main Website Store.']),
             MessageInterface::TYPE_SUCCESS
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php b/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php
index 42efc53e951d63232c43c516ea71d7b46276e437..b8da32743aefd80f8fd99d61bb68103067517fa2 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Exception/NoSuchEntityExceptionTest.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\Exception;
 
+use Magento\Framework\Phrase;
+
 class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
 {
     public function testConstructor()
@@ -15,21 +17,25 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('No such entity.', $exception->getLogMessage());
 
         $exception = new NoSuchEntityException(
-            NoSuchEntityException::MESSAGE_SINGLE_FIELD,
-            ['fieldName' => 'field', 'fieldValue' => 'value']
+            new Phrase(
+                NoSuchEntityException::MESSAGE_SINGLE_FIELD,
+                ['fieldName' => 'field', 'fieldValue' => 'value']
+            )
         );
         $this->assertEquals('No such entity with field = value', $exception->getMessage());
         $this->assertEquals(NoSuchEntityException::MESSAGE_SINGLE_FIELD, $exception->getRawMessage());
         $this->assertEquals('No such entity with field = value', $exception->getLogMessage());
 
         $exception = new NoSuchEntityException(
-            NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-            [
-                'fieldName' => 'field1',
-                'fieldValue' => 'value1',
-                'field2Name' => 'field2',
-                'field2Value' => 'value2'
-            ]
+            new Phrase(
+                NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                [
+                    'fieldName' => 'field1',
+                    'fieldValue' => 'value1',
+                    'field2Name' => 'field2',
+                    'field2Value' => 'value2'
+                ]
+            )
         );
         $this->assertEquals(
             NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php
index 713a8c76c0218a74da3c4ca61bfd92c46f59adce..214e3f39423b5ef98a51aa387b62a5dc453315d2 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateCachingTest.php
@@ -27,15 +27,23 @@ class TranslateCachingTest extends \PHPUnit_Framework_TestCase
         $model = $objectManager->get('Magento\Framework\Translate');
 
         $model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND); // this is supposed to cache the fixture
-        $this->assertEquals('Fixture Db Translation', __('Fixture String'));
+        $this->assertEquals('Fixture Db Translation', new \Magento\Framework\Phrase('Fixture String'));
 
         /** @var \Magento\Translation\Model\Resource\String $translateString */
         $translateString = $objectManager->create('Magento\Translation\Model\Resource\String');
         $translateString->saveTranslate('Fixture String', 'New Db Translation');
 
-        $this->assertEquals('Fixture Db Translation', __('Fixture String'), 'Translation is expected to be cached');
+        $this->assertEquals(
+            'Fixture Db Translation',
+            new \Magento\Framework\Phrase('Fixture String'),
+            'Translation is expected to be cached'
+        );
 
         $model->loadData(\Magento\Framework\App\Area::AREA_FRONTEND, true);
-        $this->assertEquals('New Db Translation', __('Fixture String'), 'Forced load should not use cache');
+        $this->assertEquals(
+            'New Db Translation',
+            new \Magento\Framework\Phrase('Fixture String'),
+            'Forced load should not use cache'
+        );
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php
index da1d8586a1f3939fd1da8e9673a3aff77b632b6f..4be86c6a992e4f5e48542d9741618411c8bf925d 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/TranslateTest.php
@@ -83,7 +83,7 @@ class TranslateTest extends \PHPUnit_Framework_TestCase
      */
     public function testTranslate($inputText, $expectedTranslation)
     {
-        $actualTranslation = __($inputText);
+        $actualTranslation = new \Magento\Framework\Phrase($inputText);
         $this->assertEquals($expectedTranslation, $actualTranslation);
     }
 
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php
index 2a25d44f2b656b0d6a08d07b1404b11b1557c224..6b292a49281e8830ef1e4e62f520d1489d76c474 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Validator/FactoryTest.php
@@ -23,11 +23,11 @@ class FactoryTest extends \PHPUnit_Framework_TestCase
         // Check that default translator was set
         $translator = \Magento\Framework\Validator\AbstractValidator::getDefaultTranslator();
         $this->assertInstanceOf('Magento\Framework\Translate\AdapterInterface', $translator);
-        $this->assertEquals('Message', __('Message'));
+        $this->assertEquals('Message', new \Magento\Framework\Phrase('Message'));
         $this->assertEquals('Message', $translator->translate('Message'));
         $this->assertEquals(
             'Message with "placeholder one" and "placeholder two"',
-            (string)__('Message with "%1" and "%2"', 'placeholder one', 'placeholder two')
+            (string)new \Magento\Framework\Phrase('Message with "%1" and "%2"', ['placeholder one', 'placeholder two'])
         );
     }
 }
diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php
index 1c77630c6661588ad5d1cf1fe71f1a1eb5b01041..ead4f55b11bab71d455fc6000f9158d7f8bc2ddb 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/View/Element/AbstractBlockTest.php
@@ -391,7 +391,7 @@ class AbstractBlockTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @magentoAppIsolation enabled
-     * @expectedException \Magento\Framework\Exception
+     * @expectedException \OutOfBoundsException
      */
     public function testInsertWithoutCreateBlock()
     {
diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php
index 6caf19e5e232514f1dcf7255da1ea5a4bb211f06..11c917fba00ba2ee5d7573949f9acfc64f289e2c 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/View/LayoutDirectivesTest.php
@@ -224,7 +224,7 @@ class LayoutDirectivesTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Framework\Exception
+     * @expectedException \OutOfBoundsException
      */
     public function testRemoveBroken()
     {
diff --git a/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php b/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php
index 42abd3ab3f48ba49d5308f655fbb91b6b03d686a..e2fb6987724b6f2de342839679c2fafe2c728a8e 100644
--- a/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php
+++ b/dev/tests/static/framework/Magento/Sniffs/Annotations/Helper.php
@@ -496,6 +496,8 @@ class Helper
             //       This block of the if should be removed leaving only the phtml condition when dev/tests is swept.
             // Skip all dev tests files
             $shouldFilter = true;
+        } elseif (preg_match('#(?:/|\\\\)Test(?:/|\\\\)Unit(?:/|\\\\)#', $filename)) {
+            $shouldFilter = true;
         } elseif (preg_match('/\\.phtml$/', $filename)) {
             // Skip all phtml files
             $shouldFilter = true;
diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
index e47cc2c1d2d314c6050365aeea5d2b1707bb36d0..e87c6a8441447b1c605e33196aae16c8a1d26b29 100644
--- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
+++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php
@@ -1905,7 +1905,7 @@ return [
     ['_isVatValidationEnabled', 'Magento\Customer\Controller\Account'],
     ['_createUrl', 'Magento\Customer\Controller\Account'],
     ['_extractAddress', 'Magento\Customer\Controller\Account\CreatePost', 'Magento\Customer\Controller\Account\CreatePost::extractAddress'],
-    ['_loginPostRedirect', 'Magento\Customer\Controller\Account\LoginPost', 'Magento\Customer\Controller\Account\LoginPost::loginPostRedirect'],
+    ['_loginPostRedirect', 'Magento\Customer\Controller\Account\LoginPost', 'Magento\Customer\Model\Account\Redirect::getRedirect'],
     ['_getAllowedActions', 'Magento\Customer\Controller\Account', 'Magento\Customer\Controller\Account::getAllowedActions'],
     ['isRegistrationAllowed', 'Magento\Customer\Controller\Account\CreatePost'],
     ['isRegistrationAllowed', 'Magento\Invitation\Controller\Customer\Account\CreatePost'],
@@ -2105,6 +2105,12 @@ return [
         'Magento\Integration\Helper\Validator',
         'Magento\Integration\Model\CredentialsValidator::validate'
     ],
+    ['getSuccessRedirect', 'Magento\Customer\Controller\Account\CreatePost'],
+    [
+        'loginPostRedirect',
+        'Magento\Customer\Controller\Account\LoginPost',
+        'Magento\Customer\Model\Account\Redirect::getRedirect'
+    ],
     ['isReviewOwner', 'Magento\Review\Block\Customer\View'],
     ['getRegistration', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getRegistration'],
     ['getCreateAccountUrl', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getCreateAccountUrl'],
diff --git a/lib/internal/Magento/Framework/Controller/Result/JSON.php b/lib/internal/Magento/Framework/Controller/Result/Json.php
similarity index 98%
rename from lib/internal/Magento/Framework/Controller/Result/JSON.php
rename to lib/internal/Magento/Framework/Controller/Result/Json.php
index 1876280468ce46faf536e95c9ec5a741a1b5e6f3..f1d480efec72e9ec8b610e4209bb581cbf1cb773 100644
--- a/lib/internal/Magento/Framework/Controller/Result/JSON.php
+++ b/lib/internal/Magento/Framework/Controller/Result/Json.php
@@ -14,7 +14,7 @@ use Magento\Framework\Translate\InlineInterface;
  * A possible implementation of JSON response type (instead of hardcoding json_encode() all over the place)
  * Actual for controller actions that serve ajax requests
  */
-class JSON extends AbstractResult
+class Json extends AbstractResult
 {
     /**
      * @var \Magento\Framework\Translate\InlineInterface
diff --git a/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php b/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php
new file mode 100644
index 0000000000000000000000000000000000000000..1cfc89004602d9283017ba9e28c954b2950de7a0
--- /dev/null
+++ b/lib/internal/Magento/Framework/Controller/Result/RedirectFactory.php
@@ -0,0 +1,48 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Framework\Controller\Result;
+
+use Magento\Framework\ObjectManagerInterface;
+
+class RedirectFactory
+{
+    /**
+     * Object Manager instance
+     *
+     * @var ObjectManagerInterface
+     */
+    protected $objectManager;
+
+    /**
+     * Instance name to create
+     *
+     * @var string
+     */
+    protected $instanceName;
+
+    /**
+     * @param ObjectManagerInterface $objectManager
+     * @param string $instanceName
+     */
+    public function __construct(
+        ObjectManagerInterface $objectManager,
+        $instanceName = 'Magento\Framework\Controller\Result\Redirect'
+    ) {
+        $this->objectManager = $objectManager;
+        $this->instanceName = $instanceName;
+    }
+
+    /**
+     * Create class instance with specified parameters
+     *
+     * @param array $data
+     * @return \Magento\Framework\Controller\Result\Redirect
+     */
+    public function create(array $data = [])
+    {
+        return $this->objectManager->create($this->instanceName, $data);
+    }
+}
diff --git a/lib/internal/Magento/Framework/Controller/ResultFactory.php b/lib/internal/Magento/Framework/Controller/ResultFactory.php
index f9700a534549627b20480907919a1ad4c74523bb..db78cf29c63014d7102ef03cabd1378fd6ee828d 100644
--- a/lib/internal/Magento/Framework/Controller/ResultFactory.php
+++ b/lib/internal/Magento/Framework/Controller/ResultFactory.php
@@ -30,7 +30,7 @@ class ResultFactory
      * @var array
      */
     protected $typeMap = [
-        self::TYPE_JSON     => 'Magento\Framework\Controller\Result\JSON',
+        self::TYPE_JSON     => 'Magento\Framework\Controller\Result\Json',
         self::TYPE_RAW      => 'Magento\Framework\Controller\Result\Raw',
         self::TYPE_REDIRECT => 'Magento\Framework\Controller\Result\Redirect',
         self::TYPE_FORWARD  => 'Magento\Framework\Controller\Result\Forward',
diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php
similarity index 78%
rename from lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php
rename to lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php
index 0f57fb17b0c49d4e786b556177daa291d36a1c8b..d92164f181e41db5370575589aa4c8b28057da02 100644
--- a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JSONTest.php
+++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/JsonTest.php
@@ -7,12 +7,15 @@
 namespace Magento\Framework\Controller\Test\Unit\Result;
 
 /**
- * Class JSONTest
+ * Class JsonTest
  *
- * covers Magento\Framework\Controller\Result\JSON
+ * covers Magento\Framework\Controller\Result\Json
  */
-class JSONTest extends \PHPUnit_Framework_TestCase
+class JsonTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testRenderResult()
     {
         $json = '{"data":"data"}';
@@ -29,9 +32,9 @@ class JSONTest extends \PHPUnit_Framework_TestCase
         $response = $this->getMock('Magento\Framework\App\Response\Http', ['representJson'], [], '', false);
         $response->expects($this->atLeastOnce())->method('representJson')->with($json)->will($this->returnSelf());
 
-        /** @var \Magento\Framework\Controller\Result\JSON $resultJson */
+        /** @var \Magento\Framework\Controller\Result\Json $resultJson */
         $resultJson = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
-            ->getObject('Magento\Framework\Controller\Result\JSON', ['translateInline' => $translateInline]);
+            ->getObject('Magento\Framework\Controller\Result\Json', ['translateInline' => $translateInline]);
         $resultJson->setJsonData($json);
         $this->assertSame($resultJson, $resultJson->renderResult($response));
     }
diff --git a/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..0fb551e749ac560fefe3ae3c3b4a6c71701d59ed
--- /dev/null
+++ b/lib/internal/Magento/Framework/Controller/Test/Unit/Result/RedirectFactoryTest.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Unit test for Magento\Framework\ValidatorFactory
+ *
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+// @codingStandardsIgnoreFile
+
+namespace Magento\Framework\Controller\Test\Unit\Result;
+
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+
+class RedirectFactoryTest extends \PHPUnit_Framework_TestCase
+{
+    /** @var  \Magento\Framework\ValidatorFactory */
+    private $model;
+
+    /** @var \Magento\Framework\ObjectManagerInterface | \PHPUnit_Framework_MockObject_MockObject */
+    private $objectManagerMock;
+
+    public function setUp()
+    {
+        $objectManager = new ObjectManager($this);
+        $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface');
+        $this->model = $objectManager->getObject('Magento\Framework\Controller\Result\RedirectFactory',
+            ['objectManager' => $this->objectManagerMock]
+        );
+    }
+
+    public function testCreate()
+    {
+        $redirect = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->objectManagerMock->expects($this->once())->method('create')
+            ->willReturn($redirect);
+
+        $resultRedirect = $this->model->create();
+        $this->assertInstanceOf('Magento\Framework\Controller\Result\Redirect', $resultRedirect);
+        $this->assertSame($redirect, $resultRedirect);
+    }
+}
diff --git a/lib/internal/Magento/Framework/Data/Structure.php b/lib/internal/Magento/Framework/Data/Structure.php
index 4ec2fb61cfea4af1494875e81389b6fcd107a561..6f97437a266d99e900d1d95d8482d9258c660c88 100644
--- a/lib/internal/Magento/Framework/Data/Structure.php
+++ b/lib/internal/Magento/Framework/Data/Structure.php
@@ -602,7 +602,7 @@ class Structure
     private function _assertElementExists($elementId)
     {
         if (!isset($this->_elements[$elementId])) {
-            throw new Exception("No element found with ID '{$elementId}'.");
+            throw new \OutOfBoundsException("No element found with ID '{$elementId}'.");
         }
     }
 
diff --git a/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php b/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php
index 5fd8bafce2234ebfe4549698dea1675583b41b5c..17c4e3cf39a648c04bce1183cd38b49ac8448384 100644
--- a/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php
+++ b/lib/internal/Magento/Framework/Data/Test/Unit/StructureTest.php
@@ -12,6 +12,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
      */
     protected $_structure;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->_structure = new \Magento\Framework\Data\Structure();
@@ -19,6 +22,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @param array $elements
+     * @return void
      * @dataProvider importExportElementsDataProvider
      */
     public function testConstructImportExportElements($elements)
@@ -63,6 +67,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @param array $elements
+     * @return void
      * @dataProvider importExceptionDataProvider
      * @expectedException \Magento\Framework\Exception
      */
@@ -71,13 +76,13 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->_structure->importElements($elements);
     }
 
+    /**
+     * @return array
+     */
     public function importExceptionDataProvider()
     {
         return [
             'numeric id' => [['element']],
-            'non-existing parent' => [
-                ['element' => [\Magento\Framework\Data\Structure::PARENT => 'unknown']],
-            ],
             'completely missing nested set' => [
                 ['one' => [\Magento\Framework\Data\Structure::PARENT => 'two'], 'two' => []],
             ],
@@ -100,14 +105,6 @@ class StructureTest extends \PHPUnit_Framework_TestCase
                     'three' => [\Magento\Framework\Data\Structure::PARENT => 'one'],
                 ],
             ],
-            'missing child' => [
-                [
-                    'one' => [
-                        \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.', 'three' => 't.h.r.e.e.'],
-                    ],
-                    'two' => [\Magento\Framework\Data\Structure::PARENT => 'one'],
-                ],
-            ],
             'missing reference back to parent' => [
                 ['one' => [
                     \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.'], ], 'two' => [],
@@ -139,6 +136,40 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         ];
     }
 
+    /**
+     * @param array $elements
+     * @return void
+     * @dataProvider importExceptionElementNotFoundDataProvider
+     * @expectedException \OutOfBoundsException
+     */
+    public function testImportExceptionElementNotFound($elements)
+    {
+        $this->_structure->importElements($elements);
+    }
+
+    /**
+     * @return array
+     */
+    public function importExceptionElementNotFoundDataProvider()
+    {
+        return [
+            'non-existing parent' => [
+                ['element' => [\Magento\Framework\Data\Structure::PARENT => 'unknown']],
+            ],
+            'missing child' => [
+                [
+                    'one' => [
+                        \Magento\Framework\Data\Structure::CHILDREN => ['two' => 't.w.o.', 'three' => 't.h.r.e.e.'],
+                    ],
+                    'two' => [\Magento\Framework\Data\Structure::PARENT => 'one'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * @return void
+     */
     public function testCreateGetHasElement()
     {
         $data = [uniqid() => uniqid()];
@@ -152,6 +183,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception
      */
     public function testCreateElementException()
@@ -161,6 +193,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->_structure->createElement($elementId, []);
     }
 
+    /**
+     * @return void
+     */
     public function testUnsetElement()
     {
         $this->_populateSampleStructure();
@@ -175,6 +210,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame(['one' => [], 'five' => [5]], $this->_structure->exportElements());
     }
 
+    /**
+     * @return void
+     */
     public function testSetGetAttribute()
     {
         $this->_populateSampleStructure();
@@ -187,7 +225,8 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Framework\Exception
+     * @return void
+     * @expectedException \OutOfBoundsException
      */
     public function testSetAttributeNoElementException()
     {
@@ -195,9 +234,10 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @param string $attribute
+     * @return void
      * @expectedException \InvalidArgumentException
      * @dataProvider setAttributeArgumentExceptionDataProvider
-     * @param string $attribute
      */
     public function testSetAttributeArgumentException($attribute)
     {
@@ -218,13 +258,17 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @expectedException \Magento\Framework\Exception
+     * @return void
+     * @expectedException \OutOfBoundsException
      */
     public function testGetAttributeNoElementException()
     {
         $this->_structure->getAttribute('non-existing', 'foo');
     }
 
+    /**
+     * @return void
+     */
     public function testRenameElement()
     {
         $this->_populateSampleStructure();
@@ -253,6 +297,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame(['three.5' => 'th', 'two.5' => 'tw'], $this->_structure->getChildren('four.5'));
     }
 
+    /**
+     * @return void
+     */
     public function testSetAsChild()
     {
         $this->_populateSampleStructure();
@@ -272,6 +319,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     /**
      * @param int $offset
      * @param int $expectedOffset
+     * @return void
      * @dataProvider setAsChildOffsetDataProvider
      */
     public function testSetAsChildOffset($offset, $expectedOffset)
@@ -315,6 +363,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     /**
      * @param string $elementId
      * @param string $parentId
+     * @return void
      * @expectedException \Magento\Framework\Exception
      * @dataProvider setAsChildExceptionDataProvider
      */
@@ -336,6 +385,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         return [['one', 'three'], ['one', 'one']];
     }
 
+    /**
+     * @return void
+     */
     public function testUnsetChild()
     {
         $this->_populateSampleStructure();
@@ -355,6 +407,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
      * @param int $initialOffset
      * @param int $newOffset
      * @param int $expectedOffset
+     * @return void
      * @dataProvider reorderChildDataProvider
      */
     public function testReorderChild($initialOffset, $newOffset, $expectedOffset)
@@ -404,6 +457,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception
      */
     public function testReorderChildException()
@@ -418,6 +472,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
      * @param string $sibling
      * @param int $delta
      * @param int $expectedOffset
+     * @return void
      * @dataProvider reorderSiblingDataProvider
      */
     public function testReorderToSibling($initialOffset, $sibling, $delta, $expectedOffset)
@@ -427,6 +482,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($expectedOffset, $this->_structure->reorderToSibling('parent', 'x', $sibling, $delta));
     }
 
+    /**
+     * @return array
+     */
     public function reorderSiblingDataProvider()
     {
         return [
@@ -456,6 +514,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * @expectedException \Magento\Framework\Exception
      */
     public function testReorderToSiblingException()
@@ -467,6 +526,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->_structure->reorderToSibling('one', 'three', 'two', 1);
     }
 
+    /**
+     * @return void
+     */
     public function testGetChildId()
     {
         $this->_populateSampleStructure();
@@ -474,6 +536,9 @@ class StructureTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals('five', $this->_structure->getChildId('six', 'f'));
     }
 
+    /**
+     * @return void
+     */
     public function testGetChildrenParentIdChildAlias()
     {
         $this->_structure->createElement('one', []);
@@ -499,6 +564,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @return void
      * covers \Magento\Framework\Data\Structure::addToParentGroup
      * covers \Magento\Framework\Data\Structure::getGroupChildNames
      */
@@ -542,6 +608,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Import a sample valid structure
+     * @return void
      */
     protected function _populateSampleStructure()
     {
@@ -559,6 +626,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Import a sample structure, suitable for testing elements sort order
+     * @return void
      */
     protected function _populateSampleSortStructure()
     {
diff --git a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php
index c63e32c6dd390ecebd989f98ec872b21ae0e8850..c012e04d7563b950d0b5c078ddf4ab14aaaa7bc1 100644
--- a/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php
+++ b/lib/internal/Magento/Framework/Exception/AbstractAggregateException.php
@@ -6,35 +6,23 @@
 
 namespace Magento\Framework\Exception;
 
+use Magento\Framework\Phrase;
+
 abstract class AbstractAggregateException extends LocalizedException
 {
     /**
-     * The array of errors that have been added via the addError() method.
+     * The array of errors that have been added via the addError() method
      *
-     * @var ErrorMessage[]
+     * @var \Magento\Framework\Exception\LocalizedException[]
      */
     protected $errors = [];
 
     /**
-     * The original message after being processed by the parent constructor
-     *
-     * @var string
-     */
-    protected $originalMessage;
-
-    /**
-     * The original raw message passed in via the constructor
+     * The original phrase
      *
-     * @var string
+     * @var \Magento\Framework\Phrase
      */
-    protected $originalRawMessage;
-
-    /**
-     * The original params passed in via the constructor
-     *
-     * @var array
-     */
-    protected $originalParams = [];
+    protected $originalPhrase;
 
     /**
      * An internal variable indicating how many time addError has been called
@@ -44,49 +32,44 @@ abstract class AbstractAggregateException extends LocalizedException
     private $addErrorCalls = 0;
 
     /**
-     * Initialize the exception.
+     * Initialize the exception
      *
-     * @param string     $message
-     * @param array      $params
+     * @param \Magento\Framework\Phrase $phrase
      * @param \Exception $cause
      */
-    public function __construct($message, array $params = [], \Exception $cause = null)
+    public function __construct(Phrase $phrase, \Exception $cause = null)
     {
-        $this->originalRawMessage = $message;
-        $this->originalParams = $params;
-        parent::__construct($message, $params, $cause);
-        $this->originalMessage = $this->message;
+        $this->originalPhrase = $phrase;
+        parent::__construct($phrase, $cause);
     }
 
     /**
-     * Create a new error raw message object for the message and its substitution parameters.
-     *
-     * @param string $rawMessage Exception message
-     * @param array  $params  Substitution parameters and extra error debug information
+     * Add new error into the list of exceptions
      *
+     * @param \Magento\Framework\Phrase $phrase
      * @return $this
      */
-    public function addError($rawMessage, array $params = [])
+    public function addError(Phrase $phrase)
     {
         $this->addErrorCalls++;
         if (empty($this->errors)) {
             if (1 === $this->addErrorCalls) {
-                // First call: simply overwrite the message and params
-                $this->rawMessage = $rawMessage;
-                $this->params = $params;
-                $this->message = (string)new \Magento\Framework\Phrase($rawMessage, $params);
+                // First call: simply overwrite the phrase and message
+                $this->phrase = $phrase;
+                $this->message = $phrase->render();
+                $this->logMessage = null;
             } elseif (2 === $this->addErrorCalls) {
                 // Second call: store the error from the first call and the second call in the array
-                // restore the message and params to their original value
-                $this->errors[] = new ErrorMessage($this->rawMessage, $this->params);
-                $this->errors[] = new ErrorMessage($rawMessage, $params);
-                $this->rawMessage = $this->originalRawMessage;
-                $this->params = $this->originalParams;
-                $this->message = $this->originalMessage;
+                // restore the phrase to its original value
+                $this->errors[] = new LocalizedException($this->phrase);
+                $this->errors[] = new LocalizedException($phrase);
+                $this->phrase = $this->originalPhrase;
+                $this->message = $this->originalPhrase->render();
+                $this->logMessage = null;
             }
         } else {
             // All subsequent calls after the second should reach here
-            $this->errors[] = new ErrorMessage($rawMessage, $params);
+            $this->errors[] = new LocalizedException($phrase);
         }
         return $this;
     }
@@ -102,9 +85,9 @@ abstract class AbstractAggregateException extends LocalizedException
     }
 
     /**
-     * Return the array of ErrorMessage objects. Return an empty array if no errors were added.
+     * Get the array of LocalizedException objects. Get an empty array if no errors were added.
      *
-     * @return ErrorMessage[]
+     * @return \Magento\Framework\Exception\LocalizedException[]
      */
     public function getErrors()
     {
diff --git a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php
index 507bce1aabbda031af43b37fca4a696ff932a23f..833a1166556b96a62faeaf64d0009791a5b4e313 100644
--- a/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php
+++ b/lib/internal/Magento/Framework/Exception/AlreadyExistsException.php
@@ -6,6 +6,6 @@
 
 namespace Magento\Framework\Exception;
 
-class AlreadyExistsException extends \Magento\Framework\Exception\LocalizedException
+class AlreadyExistsException extends LocalizedException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php b/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php
index afce581bf1003cfd7277dec340c94fd3dfcf6bdd..b09f61b8155ba26bd68439051681d76a8c7ce40f 100644
--- a/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php
+++ b/lib/internal/Magento/Framework/Exception/CouldNotDeleteException.php
@@ -3,7 +3,6 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Exception;
 
 class CouldNotDeleteException extends LocalizedException
diff --git a/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php b/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php
index 6dab6e987f9723dc8a99a267075cb0bfa11e069a..46fe43112da8eb341cd03eaae1515ebb9250e931 100644
--- a/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php
+++ b/lib/internal/Magento/Framework/Exception/EmailNotConfirmedException.php
@@ -3,12 +3,10 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Exception;
 
 /**
  * Class EmailNotConfirmedException
- *
  */
 class EmailNotConfirmedException extends AuthenticationException
 {
diff --git a/lib/internal/Magento/Framework/Exception/ErrorMessage.php b/lib/internal/Magento/Framework/Exception/ErrorMessage.php
deleted file mode 100644
index 0cb1c62eb184846eabfeab70cac25b4b9c4bfb39..0000000000000000000000000000000000000000
--- a/lib/internal/Magento/Framework/Exception/ErrorMessage.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/**
- * Copyright © 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
-namespace Magento\Framework\Exception;
-
-use Magento\Framework\Phrase\Renderer\Placeholder;
-
-class ErrorMessage
-{
-    /**
-     * The error message.
-     *
-     * @var string
-     */
-    private $message;
-
-    /**
-     * The message substitution parameters.
-     *
-     * @var array
-     */
-    private $params;
-
-    /**
-     * The renderer to use for retrieving the log-compatible message.
-     *
-     * @var Placeholder
-     */
-    private $renderer;
-
-    /**
-     * Initialize the error message object.
-     *
-     * @param string $message Error message
-     * @param array $parameters Message arguments (i.e. substitution parameters)
-     */
-    public function __construct($message, array $parameters = [])
-    {
-        $this->message = $message;
-        $this->params = $parameters;
-        $this->renderer = new Placeholder();
-    }
-
-    /**
-     * Return the parameters associated with this error.
-     *
-     * @return array
-     */
-    public function getParameters()
-    {
-        return $this->params;
-    }
-
-    /**
-     * Return the message localized to based on the locale of the current request.
-     *
-     * @return \Magento\Framework\Phrase
-     */
-    public function getMessage()
-    {
-        return (string)new \Magento\Framework\Phrase($this->message, $this->params);
-    }
-
-    /**
-     * Return the un-processed message, which can be used as a localization key by web service clients.
-     *
-     * @return string
-     */
-    public function getRawMessage()
-    {
-        return $this->message;
-    }
-
-    /**
-     * Return the un-localized string, but with the parameters filled in.
-     *
-     * @return string
-     */
-    public function getLogMessage()
-    {
-        return $this->renderer->render([$this->message], $this->params);
-    }
-}
diff --git a/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php b/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php
index adb3afb144cda3c810534c5667cc9f0e0dd84c3a..73a22a65116e664f73531b2f34ed1612e5e803e3 100644
--- a/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php
+++ b/lib/internal/Magento/Framework/Exception/File/LargeSizeException.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\Exception\File;
 
-class LargeSizeException extends \Magento\Framework\Exception\LocalizedException
+use Magento\Framework\Exception\LocalizedException;
+
+class LargeSizeException extends LocalizedException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/File/ValidatorException.php b/lib/internal/Magento/Framework/Exception/File/ValidatorException.php
index b2b2b9799eb9334f990577449093dc78d83d663d..a8f78f8aeb2668009a79ccdd4a0ced4ed55c5286 100644
--- a/lib/internal/Magento/Framework/Exception/File/ValidatorException.php
+++ b/lib/internal/Magento/Framework/Exception/File/ValidatorException.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\Exception\File;
 
-class ValidatorException extends \Magento\Framework\Exception\LocalizedException
+use Magento\Framework\Exception\LocalizedException;
+
+class ValidatorException extends LocalizedException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/InputException.php b/lib/internal/Magento/Framework/Exception/InputException.php
index 76fedb82de2302edb94b94d16eaa7d8073e2fadb..d71b5a168f78f5e174123362c359f488c6426bcb 100644
--- a/lib/internal/Magento/Framework/Exception/InputException.php
+++ b/lib/internal/Magento/Framework/Exception/InputException.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\Exception;
 
+use Magento\Framework\Phrase;
+
 /**
  * Exception to be thrown when there is an issue with the Input to a function call.
  */
@@ -20,13 +22,15 @@ class InputException extends AbstractAggregateException
     /**
      * Initialize the input exception.
      *
-     * @param string     $message Exception message
-     * @param array      $params  Substitution parameters
-     * @param \Exception $cause   Cause of the InputException
+     * @param \Magento\Framework\Phrase $phrase
+     * @param \Exception $cause
      */
-    public function __construct($message = self::DEFAULT_MESSAGE, $params = [], \Exception $cause = null)
+    public function __construct(Phrase $phrase = null, \Exception $cause = null)
     {
-        parent::__construct($message, $params, $cause);
+        if (is_null($phrase)) {
+            $phrase = new Phrase(self::DEFAULT_MESSAGE);
+        }
+        parent::__construct($phrase, $cause);
     }
 
     /**
@@ -35,13 +39,12 @@ class InputException extends AbstractAggregateException
      * @param string $fieldName Name of the field which had an invalid value provided.
      * @param string $fieldValue The invalid value that was provided for the field.
      * @param \Exception $cause   Cause of the InputException
-     * @return InputException
+     * @return \Magento\Framework\Exception\InputException
      */
     public static function invalidFieldValue($fieldName, $fieldValue, \Exception $cause = null)
     {
-        return new InputException(
-            self::INVALID_FIELD_VALUE,
-            ['fieldName' => $fieldName, 'value' => $fieldValue],
+        return new self(
+            new Phrase(self::INVALID_FIELD_VALUE, ['fieldName' => $fieldName, 'value' => $fieldValue]),
             $cause
         );
     }
@@ -50,10 +53,12 @@ class InputException extends AbstractAggregateException
      * Creates an InputException for a missing required field.
      *
      * @param string $fieldName Name of the missing required field.
-     * @return InputException
+     * @return \Magento\Framework\Exception\InputException
      */
     public static function requiredField($fieldName)
     {
-        return new InputException(self::REQUIRED_FIELD, ['fieldName' => $fieldName]);
+        return new self(
+            new Phrase(self::REQUIRED_FIELD, ['fieldName' => $fieldName])
+        );
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php b/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php
index 151581b7a995a5ce9978beb24fb36ec476632d12..2e1b98cac0666e8a4872854665b498f7b87a2fa4 100644
--- a/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php
+++ b/lib/internal/Magento/Framework/Exception/InvalidEmailOrPasswordException.php
@@ -7,7 +7,6 @@ namespace Magento\Framework\Exception;
 
 /**
  * Class InvalidEmailOrPasswordException
- *
  */
 class InvalidEmailOrPasswordException extends AuthenticationException
 {
diff --git a/lib/internal/Magento/Framework/Exception/LocalizedException.php b/lib/internal/Magento/Framework/Exception/LocalizedException.php
index 3ecc300c5c70aeca262ccbe04d2c5209a08942f8..1b9c96b2e7a6ea467a7693cda977dd62d32391ed 100644
--- a/lib/internal/Magento/Framework/Exception/LocalizedException.php
+++ b/lib/internal/Magento/Framework/Exception/LocalizedException.php
@@ -7,31 +7,31 @@
  */
 namespace Magento\Framework\Exception;
 
+use Magento\Framework\Phrase;
 use Magento\Framework\Phrase\Renderer\Placeholder;
 
 class LocalizedException extends \Exception
 {
-    /** @var array */
-    protected $params = [];
-
-    /** @var string */
-    protected $rawMessage;
+    /**
+     * @var \Magento\Framework\Phrase
+     */
+    protected $phrase;
 
-    /** @var Placeholder */
-    private $renderer;
+    /**
+     * @var string
+     */
+    protected $logMessage;
 
     /**
-     * @param string     $message
-     * @param array      $params
+     * Constructor
+     *
+     * @param \Magento\Framework\Phrase $phrase
      * @param \Exception $cause
      */
-    public function __construct($message, array $params = [], \Exception $cause = null)
+    public function __construct(Phrase $phrase, \Exception $cause = null)
     {
-        $this->params = $params;
-        $this->rawMessage = $message;
-        $this->renderer = new Placeholder();
-
-        parent::__construct((string)new \Magento\Framework\Phrase($message, $params), 0, $cause);
+        $this->phrase = $phrase;
+        parent::__construct($phrase->render(), 0, $cause);
     }
 
     /**
@@ -41,26 +41,30 @@ class LocalizedException extends \Exception
      */
     public function getRawMessage()
     {
-        return $this->rawMessage;
+        return $this->phrase->getText();
     }
 
     /**
-     * Get the un-localized message, but with the parameters filled in
+     * Get parameters, corresponding to placeholders in raw exception message
      *
-     * @return string
+     * @return array
      */
-    public function getLogMessage()
+    public function getParameters()
     {
-        return $this->renderer->render([$this->rawMessage], $this->params);
+        return $this->phrase->getArguments();
     }
 
     /**
-     * Returns the array of parameters in the message
+     * Get the un-localized message, but with the parameters filled in
      *
-     * @return array Parameter name => values
+     * @return string
      */
-    public function getParameters()
+    public function getLogMessage()
     {
-        return $this->params;
+        if (is_null($this->logMessage)) {
+            $renderer = new Placeholder();
+            $this->logMessage = $renderer->render([$this->getRawMessage()], $this->getParameters());
+        }
+        return $this->logMessage;
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php
index 2b4ad7129e87525c16bc8aaa8cda400b4996941a..844a8cf3316461d59640f22377dd681dc89460ff 100644
--- a/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php
+++ b/lib/internal/Magento/Framework/Exception/NoSuchEntityException.php
@@ -7,22 +7,23 @@
  */
 namespace Magento\Framework\Exception;
 
-class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedException
+use Magento\Framework\Phrase;
+
+class NoSuchEntityException extends LocalizedException
 {
     const MESSAGE_SINGLE_FIELD = 'No such entity with %fieldName = %fieldValue';
     const MESSAGE_DOUBLE_FIELDS = 'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value';
 
     /**
-     * @param string $message
-     * @param array $params
+     * @param \Magento\Framework\Phrase $phrase
      * @param \Exception $cause
      */
-    public function __construct(
-        $message = 'No such entity.',
-        array $params = [],
-        \Exception $cause = null
-    ) {
-        parent::__construct($message, $params, $cause);
+    public function __construct(Phrase $phrase = null, \Exception $cause = null)
+    {
+        if (is_null($phrase)) {
+            $phrase = new Phrase('No such entity.');
+        }
+        parent::__construct($phrase, $cause);
     }
 
     /**
@@ -30,16 +31,18 @@ class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedExcept
      *
      * @param string $fieldName
      * @param string|int $fieldValue
-     * @return NoSuchEntityException
+     * @return \Magento\Framework\Exception\NoSuchEntityException
      */
     public static function singleField($fieldName, $fieldValue)
     {
-        return new NoSuchEntityException(
-            self::MESSAGE_SINGLE_FIELD,
-            [
-                'fieldName' => $fieldName,
-                'fieldValue' => $fieldValue,
-            ]
+        return new self(
+            new Phrase(
+                self::MESSAGE_SINGLE_FIELD,
+                [
+                    'fieldName' => $fieldName,
+                    'fieldValue' => $fieldValue
+                ]
+            )
         );
     }
 
@@ -50,18 +53,20 @@ class NoSuchEntityException extends \Magento\Framework\Exception\LocalizedExcept
      * @param string|int $fieldValue
      * @param string $secondFieldName
      * @param string|int $secondFieldValue
-     * @return NoSuchEntityException
+     * @return \Magento\Framework\Exception\NoSuchEntityException
      */
     public static function doubleField($fieldName, $fieldValue, $secondFieldName, $secondFieldValue)
     {
-        return new NoSuchEntityException(
-            self::MESSAGE_DOUBLE_FIELDS,
-            [
-                'fieldName' => $fieldName,
-                'fieldValue' => $fieldValue,
-                'field2Name' => $secondFieldName,
-                'field2Value' => $secondFieldValue,
-            ]
+        return new self(
+            new Phrase(
+                self::MESSAGE_DOUBLE_FIELDS,
+                [
+                    'fieldName' => $fieldName,
+                    'fieldValue' => $fieldValue,
+                    'field2Name' => $secondFieldName,
+                    'field2Value' => $secondFieldValue,
+                ]
+            )
         );
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/SerializationException.php b/lib/internal/Magento/Framework/Exception/SerializationException.php
index 0c506c7bdfb99d6a7748421d6923db66e763ff43..e0b0dd0127a0144545848f41cf9902fe3a8a0e7d 100644
--- a/lib/internal/Magento/Framework/Exception/SerializationException.php
+++ b/lib/internal/Magento/Framework/Exception/SerializationException.php
@@ -3,23 +3,27 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Exception;
 
+use Magento\Framework\Phrase;
+
 /**
  * Serialization Exception
  */
 class SerializationException extends LocalizedException
 {
-    const TYPE_MISMATCH = 'Invalid type for value :"%value". Expected Type: "%type".';
+    const DEFAULT_MESSAGE = 'Invalid type';
+    const TYPE_MISMATCH = 'Invalid type for value: "%value". Expected Type: "%type".';
 
     /**
-     * @param string     $message
-     * @param array      $params
+     * @param \Magento\Framework\Phrase $phrase
      * @param \Exception $cause
      */
-    public function __construct($message = self::TYPE_MISMATCH, array $params = [], \Exception $cause = null)
+    public function __construct(Phrase $phrase = null, \Exception $cause = null)
     {
-        parent::__construct($message, $params, $cause);
+        if (is_null($phrase)) {
+            $phrase = new Phrase(self::DEFAULT_MESSAGE);
+        }
+        parent::__construct($phrase, $cause);
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/State/ExpiredException.php b/lib/internal/Magento/Framework/Exception/State/ExpiredException.php
index 8de49c78305e5a2c8b5288502030f3041739a1fd..2819320119413b2a2632861ebdb730a222541934 100644
--- a/lib/internal/Magento/Framework/Exception/State/ExpiredException.php
+++ b/lib/internal/Magento/Framework/Exception/State/ExpiredException.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\Exception\State;
 
-class ExpiredException extends \Magento\Framework\Exception\StateException
+use Magento\Framework\Exception\StateException;
+
+class ExpiredException extends StateException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php b/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php
index c0d2a3a3dfde788d9fbb2688a9140af9aa2dac01..550eab57e9d8f90df4952e5b1a749ae4a8b7d3e0 100644
--- a/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php
+++ b/lib/internal/Magento/Framework/Exception/State/InputMismatchException.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\Exception\State;
 
-class InputMismatchException extends \Magento\Framework\Exception\StateException
+use Magento\Framework\Exception\StateException;
+
+class InputMismatchException extends StateException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php b/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php
index c3876f232479523eb7eb455578edbb8b4be317be..b02101bcec0be816b19afb4795836437faba6622 100644
--- a/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php
+++ b/lib/internal/Magento/Framework/Exception/State/InvalidTransitionException.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\Exception\State;
 
-class InvalidTransitionException extends \Magento\Framework\Exception\StateException
+use Magento\Framework\Exception\StateException;
+
+class InvalidTransitionException extends StateException
 {
 }
diff --git a/lib/internal/Magento/Framework/Exception/StateException.php b/lib/internal/Magento/Framework/Exception/StateException.php
index 48b2d32b647c4a7898aa8e5d273c2be6c4c58003..7222cc9feda67d04caba4556e35395b6bd81bd72 100644
--- a/lib/internal/Magento/Framework/Exception/StateException.php
+++ b/lib/internal/Magento/Framework/Exception/StateException.php
@@ -3,7 +3,6 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Exception;
 
 /**
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php
index a6f50ea328c78f8c0cdf8a333021eebddd967ccb..50a32d2256421c87e3c85364c60c5fc49052e892 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthenticationExceptionTest.php
@@ -7,6 +7,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\AuthenticationException;
+use Magento\Framework\Phrase;
 
 /**
  * Class AuthenticationExceptionTest
@@ -15,11 +16,16 @@ use \Magento\Framework\Exception\AuthenticationException;
  */
 class AuthenticationExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $authenticationException = new AuthenticationException(
-            AuthenticationException::AUTHENTICATION_ERROR,
-            ['consumer_id' => 1, 'resources' => 'record2']
+            new Phrase(
+                AuthenticationException::AUTHENTICATION_ERROR,
+                ['consumer_id' => 1, 'resources' => 'record2']
+            )
         );
         $this->assertSame('An authentication error occurred.', $authenticationException->getMessage());
     }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php
index b54509cf47ea5727cee89cda70abd09ca902362c..98ec16f5d181b630600a72aa5747f7bca59ea81f 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/AuthorizationExceptionTest.php
@@ -6,14 +6,20 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\AuthorizationException;
+use Magento\Framework\Phrase;
 
 class AuthorizationExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $authorizationException = new AuthorizationException(
-            AuthorizationException::NOT_AUTHORIZED,
-            ['consumer_id' => 1, 'resources' => 'record2']
+            new Phrase(
+                AuthorizationException::NOT_AUTHORIZED,
+                ['consumer_id' => 1, 'resources' => 'record2']
+            )
         );
         $this->assertSame('Consumer is not authorized to access record2', $authorizationException->getMessage());
     }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php
index 4fc4b41432569daabbf4c16893b1e67dea29879e..17abc99ed6aa9546d584dfc68dfbfc49291dfba8 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/EmailNotConfirmedExceptionTest.php
@@ -7,6 +7,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\EmailNotConfirmedException;
+use Magento\Framework\Phrase;
 
 /**
  * Class EmailNotConfirmedExceptionTest
@@ -15,11 +16,16 @@ use \Magento\Framework\Exception\EmailNotConfirmedException;
  */
 class EmailNotConfirmedExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $emailNotConfirmedException = new EmailNotConfirmedException(
-            EmailNotConfirmedException::EMAIL_NOT_CONFIRMED,
-            ['consumer_id' => 1, 'resources' => 'record2']
+            new Phrase(
+                EmailNotConfirmedException::EMAIL_NOT_CONFIRMED,
+                ['consumer_id' => 1, 'resources' => 'record2']
+            )
         );
         $this->assertSame('Email not confirmed', $emailNotConfirmedException->getMessage());
     }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php
deleted file mode 100644
index afa046ab8be906a8186a5669535766f977e4f40d..0000000000000000000000000000000000000000
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/ErrorMessageTest.php
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-/**
- * Copyright © 2015 Magento. All rights reserved.
- * See COPYING.txt for license details.
- */
-namespace Magento\Framework\Exception\Test\Unit;
-
-use \Magento\Framework\Exception\ErrorMessage;
-
-class ErrorMessageTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * The default Phrase renderer.
-     *
-     * @var \Magento\Framework\Phrase\RendererInterface
-     */
-    private $defaultRenderer;
-
-    /**
-     * The message that has been rendered by the current Phrase renderer.
-     *
-     * @var string
-     */
-    private $renderedMessage;
-
-    /**
-     * Initialization that runs before each new test.
-     *
-     * @return void
-     */
-    public function setUp()
-    {
-        $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer();
-        $rendererMock = $this->getMock('Magento\Framework\Phrase\Renderer\Placeholder', [], [], '', false);
-        $this->renderedMessage = 'rendered message';
-        $rendererMock
-            ->expects($this->once())->method('render')->will($this->returnValue($this->renderedMessage));
-        \Magento\Framework\Phrase::setRenderer($rendererMock);
-    }
-
-    /**
-     * Restoration after each test runs. Reset the Phrase renderer back to the default one.
-     *
-     * @return void
-     */
-    public function tearDown()
-    {
-        \Magento\Framework\Phrase::setRenderer($this->defaultRenderer);
-    }
-
-    /**
-     * Verify that the constructor works properly and check all associated error message types.
-     *
-     * @param string $message The error message
-     * @param array $params The array of substitution parameters
-     * @param string $expectedLogMessage The expected output of ErrorMessage::getLogMessage()
-     *
-     * @return void
-     * @dataProvider errorMessageConstructorDataProvider
-     */
-    public function testConstructor($message, $params, $expectedLogMessage)
-    {
-        $errorMessage = new ErrorMessage($message, $params);
-
-        $this->assertEquals($this->renderedMessage, $errorMessage->getMessage());
-        $this->assertEquals($message, $errorMessage->getRawMessage());
-        $this->assertEquals($expectedLogMessage, $errorMessage->getLogMessage());
-        $this->assertEquals($params, $errorMessage->getParameters());
-    }
-
-    /**
-     * Data provider for the constructor test.
-     *
-     * @return array
-     */
-    public function errorMessageConstructorDataProvider()
-    {
-        return [
-            'withPositionalParameters' => [
-                'message %1 %2',
-                ['parameter1', 'parameter2'],
-                'message parameter1 parameter2',
-            ],
-            'withNamedParameters' => [
-                'message %key1 %key2',
-                ['key1' => 'parameter1', 'key2' => 'parameter2'],
-                'message parameter1 parameter2',
-            ],
-            'withNoParameters' => [
-                'message',
-                [],
-                'message',
-            ]
-        ];
-    }
-}
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php
index 6e3d4afa93364b959b981433ed0f5ecf12662c43..f5fee1708a6b0dc2a7063df03faae3d9eac4c8d0 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/InputExceptionTest.php
@@ -6,10 +6,8 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\InputException;
+use Magento\Framework\Phrase;
 
-/**
- * @covers \Magento\Framework\Exception\InputException
- */
 class InputExceptionTest extends \PHPUnit_Framework_TestCase
 {
     /**
@@ -21,7 +19,9 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase
     public function testConstructor()
     {
         $params = ['fieldName' => 'quantity', 'value' => -100, 'minValue' => 0];
-        $inputException = new InputException(InputException::INVALID_FIELD_MIN_VALUE, $params);
+        $inputException = new InputException(
+            new Phrase(InputException::INVALID_FIELD_MIN_VALUE, $params)
+        );
 
         $this->assertEquals(InputException::INVALID_FIELD_MIN_VALUE, $inputException->getRawMessage());
         $this->assertStringMatchesFormat('%s greater than or equal to %s', $inputException->getMessage());
@@ -51,8 +51,10 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase
         $this->assertCount(0, $inputException->getErrors());
 
         $inputException->addError(
-            InputException::INVALID_FIELD_MIN_VALUE,
-            ['fieldName' => 'weight', 'value' => -100, 'minValue' => 1]
+            new Phrase(
+                InputException::INVALID_FIELD_MIN_VALUE,
+                ['fieldName' => 'weight', 'value' => -100, 'minValue' => 1]
+            )
         );
         $this->assertTrue($inputException->wasErrorAdded());
         $this->assertCount(0, $inputException->getErrors());
@@ -67,7 +69,7 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase
             $inputException->getLogMessage()
         );
 
-        $inputException->addError(InputException::REQUIRED_FIELD, ['fieldName' => 'name']);
+        $inputException->addError(new Phrase(InputException::REQUIRED_FIELD, ['fieldName' => 'name']));
         $this->assertTrue($inputException->wasErrorAdded());
         $this->assertCount(2, $inputException->getErrors());
 
@@ -106,20 +108,20 @@ class InputExceptionTest extends \PHPUnit_Framework_TestCase
         $rawMessage = 'Foo "%var"';
         $params = ['var' => 'Bar'];
         $expectedProcessedMessage = 'Foo "Bar"';
-        $inputException = new InputException($rawMessage, $params);
+        $inputException = new InputException(new Phrase($rawMessage, $params));
         $this->assertEquals($rawMessage, $inputException->getRawMessage());
         $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
         $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
         $this->assertFalse($inputException->wasErrorAdded());
         $this->assertCount(0, $inputException->getErrors());
 
-        $inputException->addError($rawMessage, $params);
+        $inputException->addError(new Phrase($rawMessage, $params));
         $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
         $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
         $this->assertTrue($inputException->wasErrorAdded());
         $this->assertCount(0, $inputException->getErrors());
 
-        $inputException->addError($rawMessage, $params);
+        $inputException->addError(new Phrase($rawMessage, $params));
         $this->assertEquals($expectedProcessedMessage, $inputException->getMessage());
         $this->assertEquals($expectedProcessedMessage, $inputException->getLogMessage());
         $this->assertTrue($inputException->wasErrorAdded());
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php
index 8409ff81b3af6711fe0bd99114f5628f1c810b5d..34fe6d00011400a4b5bf77dc0ab5ff7d39937fe3 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/InvalidEmailOrPasswordExceptionTest.php
@@ -7,6 +7,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\InvalidEmailOrPasswordException;
+use Magento\Framework\Phrase;
 
 /**
  * Class InvalidEmailOrPasswordExceptionTest
@@ -15,11 +16,16 @@ use \Magento\Framework\Exception\InvalidEmailOrPasswordException;
  */
 class InvalidEmailOrPasswordExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $exception = new InvalidEmailOrPasswordException(
-            InvalidEmailOrPasswordException::INVALID_EMAIL_OR_PASSWORD,
-            ['consumer_id' => 1, 'resources' => 'record2']
+            new Phrase(
+                InvalidEmailOrPasswordException::INVALID_EMAIL_OR_PASSWORD,
+                ['consumer_id' => 1, 'resources' => 'record2']
+            )
         );
         $this->assertSame('Invalid email or password', $exception->getMessage());
     }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php
index 8630e4d469ccfc473848a075758a8b7ddba18244..a359192c6bbaa0c8cf907e0d450cd8e82c193e9d 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/LocalizedExceptionTest.php
@@ -6,6 +6,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Phrase;
 
 /**
  * Class LocalizedExceptionTest
@@ -20,6 +21,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
     /** @var string */
     private $renderedMessage;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer();
@@ -33,18 +37,26 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         \Magento\Framework\Phrase::setRenderer($rendererMock);
     }
 
+    /**
+     * @return void
+     */
     public function tearDown()
     {
         \Magento\Framework\Phrase::setRenderer($this->defaultRenderer);
     }
 
-    /** @dataProvider constructorParametersDataProvider */
+    /**
+     * @param string $message
+     * @param array $params
+     * @param string $expectedLogMessage
+     * @return void
+     * @dataProvider constructorParametersDataProvider
+     */
     public function testConstructor($message, $params, $expectedLogMessage)
     {
         $cause = new \Exception();
         $localizeException = new LocalizedException(
-            $message,
-            $params,
+            new Phrase($message, $params),
             $cause
         );
 
@@ -57,6 +69,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($cause, $localizeException->getPrevious());
     }
 
+    /**
+     * @return array
+     */
     public function constructorParametersDataProvider()
     {
         return [
@@ -81,6 +96,9 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         ];
     }
 
+    /**
+     * @return void
+     */
     public function testGetRawMessage()
     {
         $message =  'message %1 %2';
@@ -90,13 +108,15 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         ];
         $cause = new \Exception();
         $localizeException = new LocalizedException(
-            $message,
-            $params,
+            new Phrase($message, $params),
             $cause
         );
         $this->assertEquals($message, $localizeException->getRawMessage());
     }
 
+    /**
+     * @return void
+     */
     public function testGetParameters()
     {
         $message =  'message %1 %2';
@@ -106,14 +126,16 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         ];
         $cause = new \Exception();
         $localizeException = new LocalizedException(
-            $message,
-            $params,
+            new Phrase($message, $params),
             $cause
         );
 
         $this->assertEquals($params, $localizeException->getParameters());
     }
 
+    /**
+     * @return void
+     */
     public function testGetLogMessage()
     {
         $message =  'message %1 %2';
@@ -124,8 +146,7 @@ class LocalizedExceptionTest extends \PHPUnit_Framework_TestCase
         $cause = new \Exception();
 
         $localizeException = new LocalizedException(
-            $message,
-            $params,
+            new Phrase($message, $params),
             $cause
         );
         $expectedLogMessage = 'message parameter1 parameter2';
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php
index 9df3ef2152995a6739985a120fbc4fb3fccae472..459c8dc7686ddd8c20a7f456a62d1ee3dd156af0 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/NoSuchEntityExceptionTest.php
@@ -6,6 +6,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Phrase;
 
 /**
  * Class NoSuchEntityExceptionTest
@@ -25,6 +26,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
      */
     protected $rendererMock;
 
+    /**
+     * @return void
+     */
     public function setUp()
     {
         $this->defaultRenderer = \Magento\Framework\Phrase::getRenderer();
@@ -34,11 +38,17 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
             ->getMock();
     }
 
+    /**
+     * @return void
+     */
     public function tearDown()
     {
         \Magento\Framework\Phrase::setRenderer($this->defaultRenderer);
     }
 
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $this->renderedMessage = 'rendered message';
@@ -54,8 +64,7 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
         $expectedLogMessage = 'message parameter1 parameter2';
         $cause = new \Exception();
         $localizeException = new NoSuchEntityException(
-            $message,
-            $params,
+            new Phrase($message, $params),
             $cause
         );
 
@@ -69,8 +78,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
-     * @param $message
-     * @param $expectedMessage
+     * @param string $message
+     * @param string $expectedMessage
+     * @return void
      * @dataProvider constantsDataProvider
      */
     public function testConstants($message, $expectedMessage)
@@ -82,12 +92,17 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
         \Magento\Framework\Phrase::setRenderer($this->rendererMock);
 
         $exception = new NoSuchEntityException(
-            $message,
-            ['consumer_id' => 1, 'resources' => 'record2']
+            new Phrase(
+                $message,
+                ['consumer_id' => 1, 'resources' => 'record2']
+            )
         );
         $this->assertSame($expectedMessage, $exception->getMessage());
     }
 
+    /**
+     * @return array
+     */
     public function constantsDataProvider()
     {
         return [
@@ -102,6 +117,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
         ];
     }
 
+    /**
+     * @return void
+     */
     public function testSingleField()
     {
         $fieldName = 'storeId';
@@ -112,6 +130,9 @@ class NoSuchEntityExceptionTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testDoubleField()
     {
         $website = 'website';
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php
index c8392c6c449af1255d842582d731065fe76e0929..dff9552038031074aed2be3d231276f9070b0274 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/ExpiredExceptionTest.php
@@ -8,6 +8,7 @@
 namespace Magento\Framework\Exception\Test\Unit\State;
 
 use \Magento\Framework\Exception\State\ExpiredException;
+use Magento\Framework\Phrase;
 
 /**
  * Class ExpiredException
@@ -16,6 +17,9 @@ use \Magento\Framework\Exception\State\ExpiredException;
  */
 class ExpiredExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $instanceClass = 'Magento\Framework\Exception\State\ExpiredException';
@@ -25,7 +29,7 @@ class ExpiredExceptionTest extends \PHPUnit_Framework_TestCase
             'parameter2',
         ];
         $cause = new \Exception();
-        $stateException = new ExpiredException($message, $params, $cause);
+        $stateException = new ExpiredException(new Phrase($message, $params), $cause);
         $this->assertInstanceOf($instanceClass, $stateException);
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php
index 6d163e966c3cfa9c2793752ac0660e9654dfc62c..b961329ebf424d54d8f54807cb0333d842095cff 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InputMismatchExceptionTest.php
@@ -8,9 +8,13 @@
 namespace Magento\Framework\Exception\Test\Unit\State;
 
 use \Magento\Framework\Exception\State\InputMismatchException;
+use Magento\Framework\Phrase;
 
 class InputMismatchExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $instanceClass = 'Magento\Framework\Exception\State\InputMismatchException';
@@ -20,7 +24,7 @@ class InputMismatchExceptionTest extends \PHPUnit_Framework_TestCase
             'parameter2',
         ];
         $cause = new \Exception();
-        $stateException = new InputMismatchException($message, $params, $cause);
+        $stateException = new InputMismatchException(new Phrase($message, $params), $cause);
         $this->assertInstanceOf($instanceClass, $stateException);
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php
index abb0d21697a207b21ac7e5e9cd29999c5b3a8e0c..8f1d1bea9a67af3f266c42347e8c4c6d699e4dbb 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/State/InvalidTransitionExceptionTest.php
@@ -8,9 +8,13 @@
 namespace Magento\Framework\Exception\Test\Unit\State;
 
 use \Magento\Framework\Exception\State\InvalidTransitionException;
+use Magento\Framework\Phrase;
 
 class InvalidTransitionExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testConstructor()
     {
         $instanceClass = 'Magento\Framework\Exception\State\InvalidTransitionException';
@@ -20,7 +24,7 @@ class InvalidTransitionExceptionTest extends \PHPUnit_Framework_TestCase
             'parameter2',
         ];
         $cause = new \Exception();
-        $stateException = new InvalidTransitionException($message, $params, $cause);
+        $stateException = new InvalidTransitionException(new Phrase($message, $params), $cause);
         $this->assertInstanceOf($instanceClass, $stateException);
     }
 }
diff --git a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php
index ae719a1f075cb7b4a9e4976af2409a841e20e513..463b039fef0e8eb7342a4c1bb2d9c338c66c5bd0 100644
--- a/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php
+++ b/lib/internal/Magento/Framework/Exception/Test/Unit/StateExceptionTest.php
@@ -7,6 +7,7 @@
 namespace Magento\Framework\Exception\Test\Unit;
 
 use \Magento\Framework\Exception\StateException;
+use Magento\Framework\Phrase;
 
 /**
  * Class StateExceptionTest
@@ -15,6 +16,9 @@ use \Magento\Framework\Exception\StateException;
  */
 class StateExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testStateExceptionInstance()
     {
         $instanceClass = 'Magento\Framework\Exception\StateException';
@@ -24,7 +28,7 @@ class StateExceptionTest extends \PHPUnit_Framework_TestCase
             'parameter2',
         ];
         $cause = new \Exception();
-        $stateException = new StateException($message, $params, $cause);
+        $stateException = new StateException(new Phrase($message, $params), $cause);
         $this->assertInstanceOf($instanceClass, $stateException);
     }
 }
diff --git a/lib/internal/Magento/Framework/Filesystem/Driver/File.php b/lib/internal/Magento/Framework/Filesystem/Driver/File.php
index d50cf4fc4f534d79133eb308dc8c579ef07fb7bd..e053ca69564b780066f0d08a358a1d911f253cf8 100644
--- a/lib/internal/Magento/Framework/Filesystem/Driver/File.php
+++ b/lib/internal/Magento/Framework/Filesystem/Driver/File.php
@@ -741,4 +741,30 @@ class File implements DriverInterface
     {
         return realpath($path);
     }
+
+    /**
+     * Return correct path for link
+     *
+     * @param string $path
+     * @return mixed
+     */
+    public function getRealPathSafety($path)
+    {
+        if (strpos($path, DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) === false) {
+            return $path;
+        }
+        $pathParts = explode(DIRECTORY_SEPARATOR, $path);
+        $realPath = [];
+        foreach ($pathParts as $pathPart) {
+            if ($pathPart == '.') {
+                continue;
+            }
+            if ($pathPart == '..') {
+                array_pop($realPath);
+                continue;
+            }
+            $realPath[] = $pathPart;
+        }
+        return implode(DIRECTORY_SEPARATOR, $realPath);
+    }
 }
diff --git a/lib/internal/Magento/Framework/Filesystem/DriverInterface.php b/lib/internal/Magento/Framework/Filesystem/DriverInterface.php
index aff29eefba7ce7e5f4892f353d7d2890d5f8a86d..c02447ee8c48f1ff0a0c8a065a023a28b535c79f 100644
--- a/lib/internal/Magento/Framework/Filesystem/DriverInterface.php
+++ b/lib/internal/Magento/Framework/Filesystem/DriverInterface.php
@@ -349,6 +349,14 @@ interface DriverInterface
      */
     public function getRealPath($path);
 
+    /**
+     * Return correct path for link
+     *
+     * @param string $path
+     * @return mixed
+     */
+    public function getRealPathSafety($path);
+
     /**
      * @param string $basePath
      * @param null $path
diff --git a/lib/internal/Magento/Framework/Model/AbstractModel.php b/lib/internal/Magento/Framework/Model/AbstractModel.php
index f31fb9fc3e90c7451f605f74022d82625c1f7b5e..0a56caa62736901a42545220eb5f2ec7d1cb2766 100644
--- a/lib/internal/Magento/Framework/Model/AbstractModel.php
+++ b/lib/internal/Magento/Framework/Model/AbstractModel.php
@@ -6,6 +6,8 @@
 
 namespace Magento\Framework\Model;
 
+use Magento\Framework\Phrase;
+
 /**
  * Abstract model class
  *
@@ -447,14 +449,16 @@ abstract class AbstractModel extends \Magento\Framework\Object
      * Validate model before saving it
      *
      * @return $this
-     * @throws \Magento\Framework\Validator\ValidatorException
+     * @throws \Magento\Framework\Validator\Exception
      */
     public function validateBeforeSave()
     {
         $validator = $this->_getValidatorBeforeSave();
         if ($validator && !$validator->isValid($this)) {
             $errors = $validator->getMessages();
-            $exception = new \Magento\Framework\Validator\ValidatorException(implode(PHP_EOL, $errors));
+            $exception = new \Magento\Framework\Validator\Exception(
+                new Phrase(implode(PHP_EOL, $errors))
+            );
             foreach ($errors as $errorMessage) {
                 $exception->addMessage(new \Magento\Framework\Message\Error($errorMessage));
             }
diff --git a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
index 7b7d8c3229bd3caa227ff80509e6d077a3367021..f518409cb7e97eb78c31e91967e4b84033d833eb 100644
--- a/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
+++ b/lib/internal/Magento/Framework/Model/Resource/Db/AbstractDb.php
@@ -237,7 +237,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
     public function getIdFieldName()
     {
         if (empty($this->_idFieldName)) {
-            throw new LocalizedException((string)new \Magento\Framework\Phrase('Empty identifier field name'));
+            throw new LocalizedException(new \Magento\Framework\Phrase('Empty identifier field name'));
         }
         return $this->_idFieldName;
     }
@@ -252,7 +252,7 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
     public function getMainTable()
     {
         if (empty($this->_mainTable)) {
-            throw new LocalizedException((string)new \Magento\Framework\Phrase('Empty main table name'));
+            throw new LocalizedException(new \Magento\Framework\Phrase('Empty main table name'));
         }
         return $this->getTable($this->_mainTable);
     }
@@ -658,9 +658,9 @@ abstract class AbstractDb extends \Magento\Framework\Model\Resource\AbstractReso
 
         if (!empty($existent)) {
             if (count($existent) == 1) {
-                $error = (string)new \Magento\Framework\Phrase('%1 already exists.', [$existent[0]]);
+                $error = new \Magento\Framework\Phrase('%1 already exists.', [$existent[0]]);
             } else {
-                $error = (string)new \Magento\Framework\Phrase('%1 already exist.', [implode(', ', $existent)]);
+                $error = new \Magento\Framework\Phrase('%1 already exist.', [implode(', ', $existent)]);
             }
             throw new AlreadyExistsException($error);
         }
diff --git a/lib/internal/Magento/Framework/Oauth/Exception.php b/lib/internal/Magento/Framework/Oauth/Exception.php
index e35fd786c786f002b4a7dd791ffd1f1ee5927be8..24c08f73b09cade25a527a0e218433b3a4212e02 100644
--- a/lib/internal/Magento/Framework/Oauth/Exception.php
+++ b/lib/internal/Magento/Framework/Oauth/Exception.php
@@ -3,7 +3,6 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Oauth;
 
 use Magento\Framework\Exception\AuthenticationException;
diff --git a/lib/internal/Magento/Framework/Oauth/Oauth.php b/lib/internal/Magento/Framework/Oauth/Oauth.php
index 88c23929222216718c3cb076a029e745f707e9ad..1d397d70abbf8a767bfe37706776ae2cf08befb5 100644
--- a/lib/internal/Magento/Framework/Oauth/Oauth.php
+++ b/lib/internal/Magento/Framework/Oauth/Oauth.php
@@ -5,6 +5,8 @@
  */
 namespace Magento\Framework\Oauth;
 
+use Magento\Framework\Phrase;
+
 class Oauth implements OauthInterface
 {
     /**
@@ -175,8 +177,10 @@ class Oauth implements OauthInterface
     {
         if (!in_array($params['oauth_signature_method'], self::getSupportedSignatureMethods())) {
             throw new OauthInputException(
-                'Signature method %1 is not supported',
-                [$params['oauth_signature_method']]
+                new Phrase(
+                    'Signature method %1 is not supported',
+                    [$params['oauth_signature_method']]
+                )
             );
         }
 
@@ -193,7 +197,7 @@ class Oauth implements OauthInterface
         );
 
         if ($calculatedSign != $params['oauth_signature']) {
-            throw new Exception('Invalid signature');
+            throw new Exception(new Phrase('Invalid signature'));
         }
     }
 
@@ -208,7 +212,7 @@ class Oauth implements OauthInterface
     {
         // validate version if specified
         if ('1.0' != $version) {
-            throw new OauthInputException('OAuth version %1 is not supported', [$version]);
+            throw new OauthInputException(new Phrase('OAuth version %1 is not supported', [$version]));
         }
     }
 
@@ -245,14 +249,16 @@ class Oauth implements OauthInterface
             $protocolParams['oauth_token']
         )
         ) {
-            throw new OauthInputException('Token is not the correct length');
+            throw new OauthInputException(new Phrase('Token is not the correct length'));
         }
 
         // Validate signature method.
         if (!in_array($protocolParams['oauth_signature_method'], self::getSupportedSignatureMethods())) {
             throw new OauthInputException(
-                'Signature method %1 is not supported',
-                [$protocolParams['oauth_signature_method']]
+                new Phrase(
+                    'Signature method %1 is not supported',
+                    [$protocolParams['oauth_signature_method']]
+                )
             );
         }
 
@@ -277,7 +283,7 @@ class Oauth implements OauthInterface
         $exception = new OauthInputException();
         foreach ($requiredParams as $param) {
             if (!isset($protocolParams[$param])) {
-                $exception->addError(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]);
+                $exception->addError(new Phrase(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]));
             }
         }
         if ($exception->wasErrorAdded()) {
diff --git a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php
index f7e8566a9d1ac383c1bdb575896880bc512486f7..fd5788a596e0fc9a200cd1264165421d5b7c264c 100644
--- a/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php
+++ b/lib/internal/Magento/Framework/Oauth/Test/Unit/Helper/RequestTest.php
@@ -7,6 +7,8 @@
  */
 namespace Magento\Framework\Oauth\Test\Unit\Helper;
 
+use Magento\Framework\Phrase;
+
 class RequestTest extends \PHPUnit_Framework_TestCase
 {
     /** @var \Magento\Framework\Oauth\Helper\Request */
@@ -15,6 +17,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
     /** @var \Magento\Framework\App\Response\Http */
     protected $response;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         $this->oauthRequestHelper = new \Magento\Framework\Oauth\Helper\Request();
@@ -27,12 +32,18 @@ class RequestTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     protected function tearDown()
     {
         unset($this->oauthRequestHelper, $this->response);
     }
 
     /**
+     * @param \Exception $exception
+     * @param array $expected
+     * @return void
      * @dataProvider dataProviderForPrepareErrorResponseTest
      */
     public function testPrepareErrorResponse($exception, $expected)
@@ -46,11 +57,14 @@ class RequestTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals(['oauth_problem' => $expected[0]], $errorResponse);
     }
 
+    /**
+     * @return array
+     */
     public function dataProviderForPrepareErrorResponseTest()
     {
         return [
             [
-                new \Magento\Framework\Oauth\OauthInputException('msg'),
+                new \Magento\Framework\Oauth\OauthInputException(new Phrase('msg')),
                 ['msg', \Magento\Framework\Oauth\Helper\Request::HTTP_BAD_REQUEST],
             ],
             [
@@ -68,6 +82,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @param string $url
+     * @param string $host
+     * @return void
      * @dataProvider hostsDataProvider
      */
     public function testGetRequestUrl($url, $host)
@@ -87,6 +104,9 @@ class RequestTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($url, $this->oauthRequestHelper->getRequestUrl($httpRequestMock));
     }
 
+    /**
+     * @return array
+     */
     public function hostsDataProvider()
     {
         return  [
diff --git a/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php b/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php
index ec368c3308a67f37b2cb3da768472c4d85117d01..a5b658b59d2bbbabb44448486dfb81e411cb2703 100644
--- a/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php
+++ b/lib/internal/Magento/Framework/Oauth/Test/Unit/OauthInputExceptionTest.php
@@ -6,16 +6,20 @@
 namespace Magento\Framework\Oauth\Test\Unit;
 
 use \Magento\Framework\Oauth\OauthInputException;
+use Magento\Framework\Phrase;
 
 class OauthInputExceptionTest extends \PHPUnit_Framework_TestCase
 {
+    /**
+     * @return void
+     */
     public function testGetAggregatedErrorMessage()
     {
         $exception = new OauthInputException();
         foreach (['field1', 'field2'] as $param) {
-            $exception->addError(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]);
+            $exception->addError(new Phrase(OauthInputException::REQUIRED_FIELD, ['fieldName' => $param]));
         }
-        $exception->addError('Message with period.');
+        $exception->addError(new Phrase('Message with period.'));
 
         $this->assertEquals(
             'field1 is a required field, field2 is a required field, Message with period',
@@ -23,6 +27,9 @@ class OauthInputExceptionTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return void
+     */
     public function testGetAggregatedErrorMessageNoError()
     {
         $exception = new OauthInputException();
diff --git a/lib/internal/Magento/Framework/Phrase.php b/lib/internal/Magento/Framework/Phrase.php
index 80dc48cac216579f9b412259683714f42a0bf2d0..02c4e0c063c63a36ae430ad59ac233d43b9417ac 100644
--- a/lib/internal/Magento/Framework/Phrase.php
+++ b/lib/internal/Magento/Framework/Phrase.php
@@ -17,21 +17,21 @@ class Phrase implements JsonSerializable
      *
      * @var RendererInterface
      */
-    private static $_renderer;
+    private static $renderer;
 
     /**
      * String for rendering
      *
      * @var string
      */
-    private $_text;
+    private $text;
 
     /**
      * Arguments for placeholder values
      *
      * @var array
      */
-    private $_arguments;
+    private $arguments;
 
     /**
      * Set default Phrase renderer
@@ -41,7 +41,7 @@ class Phrase implements JsonSerializable
      */
     public static function setRenderer(RendererInterface $renderer)
     {
-        self::$_renderer = $renderer;
+        self::$renderer = $renderer;
     }
 
     /**
@@ -51,7 +51,7 @@ class Phrase implements JsonSerializable
      */
     public static function getRenderer()
     {
-        return self::$_renderer;
+        return self::$renderer;
     }
 
     /**
@@ -62,8 +62,28 @@ class Phrase implements JsonSerializable
      */
     public function __construct($text, array $arguments = [])
     {
-        $this->_text = (string)$text;
-        $this->_arguments = $arguments;
+        $this->text = (string)$text;
+        $this->arguments = $arguments;
+    }
+
+    /**
+     * Get phrase base text
+     *
+     * @return string
+     */
+    public function getText()
+    {
+        return $this->text;
+    }
+
+    /**
+     * Get phrase message arguments
+     *
+     * @return array
+     */
+    public function getArguments()
+    {
+        return $this->arguments;
     }
 
     /**
@@ -73,7 +93,7 @@ class Phrase implements JsonSerializable
      */
     public function render()
     {
-        return self::$_renderer ? self::$_renderer->render([$this->_text], $this->_arguments) : $this->_text;
+        return self::$renderer ? self::$renderer->render([$this->text], $this->arguments) : $this->text;
     }
 
     /**
diff --git a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php
index 496416ff379e4f24a877ddb27fabe17a5535e104..b2e1940f123b17a71d0f917fae11bf84ebcbc49b 100644
--- a/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php
+++ b/lib/internal/Magento/Framework/Reflection/Test/Unit/TypeProcessorTest.php
@@ -175,7 +175,7 @@ class TypeProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * @expectedException \Magento\Framework\Exception\SerializationException
-     * @expectedExceptionMessage Invalid type for value :"integer". Expected Type: "int[]".
+     * @expectedExceptionMessage Invalid type for value: "integer". Expected Type: "int[]".
      */
     public function testProcessSimpleTypeInvalidType()
     {
diff --git a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php
index 38d65da521c7b9aee6e3d92a6948e55ebc1adc32..7a2f5f2dd2f137d5996dfc130649842f1300388c 100644
--- a/lib/internal/Magento/Framework/Reflection/TypeProcessor.php
+++ b/lib/internal/Magento/Framework/Reflection/TypeProcessor.php
@@ -8,6 +8,7 @@ namespace Magento\Framework\Reflection;
 use Magento\Framework\Exception\SerializationException;
 use Zend\Code\Reflection\ClassReflection;
 use Zend\Code\Reflection\ParameterReflection;
+use Magento\Framework\Phrase;
 
 /**
  * Type processor of config reader properties
@@ -430,8 +431,10 @@ class TypeProcessor
             foreach (array_keys($value) as $key) {
                 if ($value !== null && !settype($value[$key], $arrayItemType)) {
                     throw new SerializationException(
-                        SerializationException::TYPE_MISMATCH,
-                        ['value' => $value, 'type' => $type]
+                        new Phrase(
+                            SerializationException::TYPE_MISMATCH,
+                            ['value' => $value, 'type' => $type]
+                        )
                     );
                 }
             }
@@ -440,14 +443,18 @@ class TypeProcessor
         } elseif (!$isArrayType && !is_array($value)) {
             if ($value !== null && $type !== self::ANY_TYPE && !$this->setType($value, $type)) {
                 throw new SerializationException(
-                    SerializationException::TYPE_MISMATCH,
-                    ['value' => (string)$value, 'type' => $type]
+                    new Phrase(
+                        SerializationException::TYPE_MISMATCH,
+                        ['value' => (string)$value, 'type' => $type]
+                    )
                 );
             }
         } else {
             throw new SerializationException(
-                SerializationException::TYPE_MISMATCH,
-                ['value' => gettype($value), 'type' => $type]
+                new Phrase(
+                    SerializationException::TYPE_MISMATCH,
+                    ['value' => gettype($value), 'type' => $type]
+                )
             );
         }
         return $value;
diff --git a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php
index 10d9f65449c7c4d544d79b6e5f45cf9270f1c8f9..68e3fdea45acb09d8fe798133014d7c89c7339fb 100644
--- a/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php
+++ b/lib/internal/Magento/Framework/Search/Dynamic/Algorithm/Repository.php
@@ -49,7 +49,9 @@ class Repository
     {
         if (!isset($this->instances[$algorithmType])) {
             if (!isset($this->algorithms[$algorithmType])) {
-                throw new LocalizedException($algorithmType . ' was not found in algorithms');
+                throw new LocalizedException(
+                    new \Magento\Framework\Phrase('%1 was not found in algorithms', [$algorithmType])
+                );
             }
 
             $className = $this->algorithms[$algorithmType];
@@ -57,7 +59,10 @@ class Repository
 
             if (!$model instanceof AlgorithmInterface) {
                 throw new LocalizedException(
-                    $className . ' doesn\'t extends \Magento\Framework\Search\Dynamic\Algorithm\AlgorithmInterface'
+                    new \Magento\Framework\Phrase(
+                        '%1 doesn\'t extends \Magento\Framework\Search\Dynamic\Algorithm\AlgorithmInterface',
+                        [$className]
+                    )
                 );
             }
             $this->instances[$algorithmType] = $model;
diff --git a/lib/internal/Magento/Framework/Search/Request/Cleaner.php b/lib/internal/Magento/Framework/Search/Request/Cleaner.php
index b3182007c3a3d9fe7617654a8f39e803b201bdc2..aa547e211418654f91e650529f48cb625d223e07 100644
--- a/lib/internal/Magento/Framework/Search/Request/Cleaner.php
+++ b/lib/internal/Magento/Framework/Search/Request/Cleaner.php
@@ -7,6 +7,7 @@ namespace Magento\Framework\Search\Request;
 
 use Magento\Framework\Exception\StateException;
 use Magento\Framework\Search\Request\Aggregation\StatusInterface as AggregationStatus;
+use Magento\Framework\Phrase;
 
 class Cleaner
 {
@@ -73,7 +74,9 @@ class Cleaner
         if (!isset($this->requestData['queries'][$queryName])) {
             throw new \Exception('Query ' . $queryName . ' does not exist');
         } elseif (in_array($queryName, $this->mappedQueries)) {
-            throw new StateException('Cycle found. Query %1 already used in request hierarchy', [$queryName]);
+            throw new StateException(
+                new Phrase('Cycle found. Query %1 already used in request hierarchy', [$queryName])
+            );
         }
         $this->mappedQueries[] = $queryName;
         $query = $this->requestData['queries'][$queryName];
@@ -139,7 +142,9 @@ class Cleaner
         if (!isset($this->requestData['filters'][$filterName])) {
             throw new \Exception('Filter ' . $filterName . ' does not exist');
         } elseif (in_array($filterName, $this->mappedFilters)) {
-            throw new StateException('Cycle found. Filter %1 already used in request hierarchy', [$filterName]);
+            throw new StateException(
+                new Phrase('Cycle found. Filter %1 already used in request hierarchy', [$filterName])
+            );
         }
         $this->mappedFilters[] = $filterName;
         $filter = $this->requestData['filters'][$filterName];
diff --git a/lib/internal/Magento/Framework/Search/Request/Mapper.php b/lib/internal/Magento/Framework/Search/Request/Mapper.php
index 488880d07a00053431c277993b0715cc95f01b69..e2dcbef74cda6ab201ed6bdd7dc6b3dcda916cd7 100644
--- a/lib/internal/Magento/Framework/Search/Request/Mapper.php
+++ b/lib/internal/Magento/Framework/Search/Request/Mapper.php
@@ -7,6 +7,7 @@ namespace Magento\Framework\Search\Request;
 
 use Magento\Framework\Exception\StateException;
 use Magento\Framework\Search\Request\Query\Filter;
+use Magento\Framework\Phrase;
 
 /**
  * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -106,7 +107,9 @@ class Mapper
         if (!isset($this->queries[$queryName])) {
             throw new \Exception('Query ' . $queryName . ' does not exist');
         } elseif (in_array($queryName, $this->mappedQueries)) {
-            throw new StateException('Cycle found. Query %1 already used in request hierarchy', [$queryName]);
+            throw new StateException(
+                new Phrase('Cycle found. Query %1 already used in request hierarchy', [$queryName])
+            );
         }
         $this->mappedQueries[] = $queryName;
         $query = $this->queries[$queryName];
@@ -173,7 +176,9 @@ class Mapper
         if (!isset($this->filters[$filterName])) {
             throw new \Exception('Filter ' . $filterName . ' does not exist');
         } elseif (in_array($filterName, $this->mappedFilters)) {
-            throw new StateException('Cycle found. Filter %1 already used in request hierarchy', [$filterName]);
+            throw new StateException(
+                new Phrase('Cycle found. Filter %1 already used in request hierarchy', [$filterName])
+            );
         }
         $this->mappedFilters[] = $filterName;
         $filter = $this->filters[$filterName];
@@ -286,7 +291,7 @@ class Mapper
         $allElements = array_keys($elements);
         $notUsedElements = implode(', ', array_diff($allElements, $mappedElements));
         if (!empty($notUsedElements)) {
-            throw new StateException($errorMessage, [$notUsedElements]);
+            throw new StateException(new Phrase($errorMessage, [$notUsedElements]));
         }
     }
 
@@ -348,7 +353,8 @@ class Mapper
                     );
                     break;
                 default:
-                    throw new StateException('Invalid bucket type');
+                    throw new StateException(new Phrase('Invalid bucket type'));
+                    break;
             }
             $buckets[] = $bucket;
         }
diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php
index a481b6cbb4b3097f2775f8f5412bc28e8d3234d6..5f3ec17ff6a771daaebb2634b659e8ca3ddc03d1 100644
--- a/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php
+++ b/lib/internal/Magento/Framework/Stdlib/Cookie/CookieSizeLimitReachedException.php
@@ -3,7 +3,6 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Stdlib\Cookie;
 
 use Magento\Framework\Exception\LocalizedException;
diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php
index d215c3a3a47d71756b2977d31e6a80029aec44d3..81ff3e90f0cc050b565862ac67a3105c0d2ce724 100644
--- a/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php
+++ b/lib/internal/Magento/Framework/Stdlib/Cookie/FailureToSendException.php
@@ -3,7 +3,6 @@
  * Copyright © 2015 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-
 namespace Magento\Framework\Stdlib\Cookie;
 
 use Magento\Framework\Exception\LocalizedException;
diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php
index c555946a187b2b38c9bea4c6303d1687e19ad949..611683a912530eecd88517db7fc1ff40c8ed5b28 100644
--- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php
+++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php
@@ -8,6 +8,7 @@ namespace Magento\Framework\Stdlib\Cookie;
 
 use Magento\Framework\Exception\InputException;
 use Magento\Framework\Stdlib\CookieManagerInterface;
+use Magento\Framework\Phrase;
 
 /**
  * CookieManager helps manage the setting, retrieving and deleting of cookies.
@@ -125,9 +126,13 @@ class PhpCookieManager implements CookieManagerInterface
         if (!$phpSetcookieSuccess) {
             $params['name'] = $name;
             if ($value == '') {
-                throw new FailureToSendException('Unable to delete the cookie with cookieName = %name', $params);
+                throw new FailureToSendException(
+                    new Phrase('Unable to delete the cookie with cookieName = %name', $params)
+                );
             } else {
-                throw new FailureToSendException('Unable to send the cookie with cookieName = %name', $params);
+                throw new FailureToSendException(
+                    new Phrase('Unable to send the cookie with cookieName = %name', $params)
+                );
             }
         }
     }
@@ -160,7 +165,9 @@ class PhpCookieManager implements CookieManagerInterface
     {
         if ($name == '' || preg_match("/[=,; \t\r\n\013\014]/", $name)) {
             throw new InputException(
-                'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014'
+                new Phrase(
+                    'Cookie name cannot be empty and cannot contain these characters: =,; \\t\\r\\n\\013\\014'
+                )
             );
         }
 
@@ -174,17 +181,19 @@ class PhpCookieManager implements CookieManagerInterface
 
         if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) {
             throw new CookieSizeLimitReachedException(
-                'Unable to send the cookie. Maximum number of cookies would be exceeded.'
+                new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.')
             );
         }
 
         if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) {
             throw new CookieSizeLimitReachedException(
-                "Unable to send the cookie. Size of '%name' is %size bytes.",
-                [
-                    'name' => $name,
-                    'size' => $sizeOfCookie,
-                ]
+                new Phrase(
+                    'Unable to send the cookie. Size of \'%name\' is %size bytes.',
+                    [
+                        'name' => $name,
+                        'size' => $sizeOfCookie,
+                    ]
+                )
             );
         }
     }
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
index 2bd6553b4fb725a8b848497acf89c92e646f6c50..ab75ed3fd336a7bbf4a5c9bbe8232828c24fd67d 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php
@@ -233,7 +233,7 @@ class Timezone implements TimezoneInterface
      * @param null $locale
      * @param null $timezone
      * @param string|null $pattern
-     * @return mixed
+     * @return string
      */
     public function formatDateTime(
         \DateTimeInterface $date,
diff --git a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php
index 48bbbc73796dba44f8d925ac6e56a61641363d80..75c865b542a0ab78a4d77870f7de12308b2bdec8 100644
--- a/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php
+++ b/lib/internal/Magento/Framework/Stdlib/DateTime/TimezoneInterface.php
@@ -122,7 +122,7 @@ interface TimezoneInterface
      * @param null $locale
      * @param null $timezone
      * @param string|null $pattern
-     * @return mixed
+     * @return string
      */
     public function formatDateTime(
         \DateTimeInterface $date,
diff --git a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php
old mode 100644
new mode 100755
index 3cae817ba9d3e88f9e84b2e00dc1c1033a04ee07..79a257b4ff77ceb505138f1cc486499c9ee06ca3
--- a/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php
+++ b/lib/internal/Magento/Framework/Test/Unit/PhraseTest.php
@@ -5,91 +5,123 @@
  */
 namespace Magento\Framework\Test\Unit;
 
+use \Magento\Framework\Phrase;
+
 class PhraseTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * @var \Magento\Framework\Phrase
+     * @var \Magento\Framework\Phrase\RendererInterface
      */
-    protected $phrase;
+    protected $defaultRenderer;
 
     /**
-     * @var \Magento\Framework\Phrase\RendererInterface|PHPUnit_Framework_MockObject_MockObject
+     * @var \Magento\Framework\Phrase\RendererInterface|\PHPUnit_Framework_MockObject_MockObject
      */
-    protected $renderer;
+    protected $rendererMock;
 
+    /**
+     * SetUp method
+     *
+     * @return void
+     */
     protected function setUp()
     {
-        $this->renderer = $this->getMock('Magento\Framework\Phrase\RendererInterface');
-        \Magento\Framework\Phrase::setRenderer($this->renderer);
+        $this->defaultRenderer = Phrase::getRenderer();
+        $this->rendererMock = $this->getMockBuilder('Magento\Framework\Phrase\RendererInterface')
+            ->getMock();
     }
 
+    /**
+     * Tear down
+     *
+     * @return void
+     */
     protected function tearDown()
     {
-        $this->removeRendererFromPhrase();
-        \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder());
+        Phrase::setRenderer($this->defaultRenderer);
     }
 
+    /**
+     * Test rendering
+     *
+     * @return void
+     */
     public function testRendering()
     {
         $text = 'some text';
         $arguments = ['arg1', 'arg2'];
         $result = 'rendered text';
-        $this->phrase = new \Magento\Framework\Phrase($text, $arguments);
-
-        $this->renderer->expects(
-            $this->once()
-        )->method(
-            'render'
-        )->with(
-            [$text],
-            $arguments
-        )->will(
-            $this->returnValue($result)
-        );
-
-        $this->assertEquals($result, $this->phrase->render());
-    }
+        $phrase = new Phrase($text, $arguments);
+        Phrase::setRenderer($this->rendererMock);
 
-    public function testRenderingWithoutRenderer()
-    {
-        $this->removeRendererFromPhrase();
-        $result = 'some text';
-        $this->phrase = new \Magento\Framework\Phrase($result);
+        $this->rendererMock->expects($this->once())
+            ->method('render')
+            ->with([$text], $arguments)
+            ->willReturn($result);
 
-        $this->assertEquals($result, $this->phrase->render());
+        $this->assertEquals($result, $phrase->render());
     }
 
+    /**
+     * Test defers rendering
+     *
+     * @return void
+     */
     public function testDefersRendering()
     {
-        $this->renderer->expects($this->never())->method('render');
-        $this->phrase = new \Magento\Framework\Phrase('some text');
+        $this->rendererMock->expects($this->never())
+            ->method('render');
+
+        new Phrase('some text');
     }
 
+    /**
+     * Test that to string is alias to render
+     *
+     * @return void
+     */
     public function testThatToStringIsAliasToRender()
     {
         $text = 'some text';
         $arguments = ['arg1', 'arg2'];
         $result = 'rendered text';
-        $this->phrase = new \Magento\Framework\Phrase($text, $arguments);
-
-        $this->renderer->expects(
-            $this->once()
-        )->method(
-            'render'
-        )->with(
-            [$text],
-            $arguments
-        )->will(
-            $this->returnValue($result)
-        );
-
-        $this->assertEquals($result, (string) $this->phrase);
+        $phrase = new Phrase($text, $arguments);
+        Phrase::setRenderer($this->rendererMock);
+
+        $this->rendererMock->expects($this->once())
+            ->method('render')
+            ->with([$text], $arguments)
+            ->willReturn($result);
+
+        $this->assertEquals($result, (string)$phrase);
+    }
+
+    /**
+     * Test get text
+     *
+     * @return void
+     */
+    public function testGetText()
+    {
+        $text = 'some text';
+        $phrase = new Phrase($text);
+
+        $this->assertEquals($text, $phrase->getText());
     }
 
-    protected function removeRendererFromPhrase()
+    /**
+     * Test get arguments
+     *
+     * @return void
+     */
+    public function testGetArguments()
     {
-        $property = new \ReflectionProperty('Magento\Framework\Phrase', '_renderer');
-        $property->setAccessible(true);
-        $property->setValue($this->phrase, null);
+        $text = 'some text';
+        $arguments = ['arg1', 'arg2'];
+        $phrase1 = new Phrase($text);
+        $phrase2 = new Phrase($text, $arguments);
+
+        $this->assertEquals([], $phrase1->getArguments());
+        $this->assertEquals($arguments, $phrase2->getArguments());
     }
 }
diff --git a/lib/internal/Magento/Framework/Validator/ValidatorException.php b/lib/internal/Magento/Framework/Validator/Exception.php
similarity index 78%
rename from lib/internal/Magento/Framework/Validator/ValidatorException.php
rename to lib/internal/Magento/Framework/Validator/Exception.php
index fe46e24b83c92ac3bef04776d6ae1c56c642588a..ba8e1dfe2eaebd1c9e42a5399d1ffb9dac80f4ba 100644
--- a/lib/internal/Magento/Framework/Validator/ValidatorException.php
+++ b/lib/internal/Magento/Framework/Validator/Exception.php
@@ -7,10 +7,15 @@
  */
 namespace Magento\Framework\Validator;
 
+use Magento\Framework\Exception\InputException;
+use Magento\Framework\Phrase;
+use Magento\Framework\Message\AbstractMessage;
+use Magento\Framework\Message\Error;
+
 /**
  * Exception to be thrown when an validation data is failed
  */
-class ValidatorException extends \Magento\Framework\Exception\InputException
+class Exception extends InputException
 {
     /**
      * @var array
@@ -20,14 +25,12 @@ class ValidatorException extends \Magento\Framework\Exception\InputException
     /**
      * Constructor
      *
-     * @param string $message
-     * @param [] $params
+     * @param \Magento\Framework\Phrase $phrase
      * @param \Exception $cause
      * @param array $messages Validation error messages
      */
     public function __construct(
-        $message = self::DEFAULT_MESSAGE,
-        $params = [],
+        Phrase $phrase = null,
         \Exception $cause = null,
         array $messages = []
     ) {
@@ -39,11 +42,12 @@ class ValidatorException extends \Magento\Framework\Exception\InputException
                         $message .= PHP_EOL;
                     }
                     $message .= $propertyMessage;
-                    $this->addMessage(new \Magento\Framework\Message\Error($propertyMessage));
+                    $this->addMessage(new Error($propertyMessage));
                 }
             }
+            $phrase = new Phrase($message);
         }
-        parent::__construct($message, $params, $cause);
+        parent::__construct($phrase, $cause);
     }
 
     /**
@@ -52,7 +56,7 @@ class ValidatorException extends \Magento\Framework\Exception\InputException
      * @param \Magento\Framework\Message\AbstractMessage $message
      * @return $this
      */
-    public function addMessage(\Magento\Framework\Message\AbstractMessage $message)
+    public function addMessage(AbstractMessage $message)
     {
         if (!isset($this->messages[$message->getType()])) {
             $this->messages[$message->getType()] = [];
diff --git a/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php b/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php
index 37af5112d911d67994acc8fddc1d9395d1797309..1db22e3fdbdfed4ceb3d558c0b9ce5a299805293 100644
--- a/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php
+++ b/lib/internal/Magento/Framework/Validator/Test/Unit/ExceptionTest.php
@@ -6,23 +6,21 @@
 
 namespace Magento\Framework\Validator\Test\Unit;
 
-use Magento\Framework\Exception\InputException;
-
 /**
- * Test case for \Magento\Framework\Validator\ValidatorException
+ * Test case for \Magento\Framework\Validator\Exception
  */
 class ExceptionTest extends \PHPUnit_Framework_TestCase
 {
     /**
-     * Testing \Magento\Framework\Validator\ValidatorException::getMessage
+     * Testing \Magento\Framework\Validator\Exception::getMessage
+     * @return void
      */
     public function testGetMessage()
     {
         $expectedMessage = 'error1' . PHP_EOL . 'error2' . PHP_EOL . 'error3';
         $messages = ['field1' => ['error1', 'error2'], 'field2' => ['error3']];
-        $exception = new \Magento\Framework\Validator\ValidatorException(
-            InputException::DEFAULT_MESSAGE,
-            [],
+        $exception = new \Magento\Framework\Validator\Exception(
+            null,
             null,
             $messages
         );
diff --git a/lib/internal/Magento/Framework/View/Asset/Config.php b/lib/internal/Magento/Framework/View/Asset/Config.php
index c18ffaeebabc07f72010e892213be61aac656ab7..1fa3bbde781383f5873c742fe0c358368fa61f46 100644
--- a/lib/internal/Magento/Framework/View/Asset/Config.php
+++ b/lib/internal/Magento/Framework/View/Asset/Config.php
@@ -4,11 +4,10 @@
  * See COPYING.txt for license details.
  */
 
-// @codingStandardsIgnoreFile
-
 namespace Magento\Framework\View\Asset;
 
 use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
 
 /**
  * View asset configuration interface
@@ -41,14 +40,19 @@ class Config implements \Magento\Framework\View\Asset\ConfigInterface
     const XML_PATH_JS_BUNDLING = 'dev/js/enable_js_bundling';
 
     /**
-     * @var \Magento\Framework\App\Config\ScopeConfigInterface
+     * XML path for HTML minification configuration
+     */
+    const XML_PATH_MINIFICATION_HTML = 'dev/template/minify_html';
+
+    /**
+     * @var ScopeConfigInterface
      */
     protected $scopeConfig;
 
     /**
-     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
+     * @param ScopeConfigInterface $scopeConfig
      */
-    public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
+    public function __construct(ScopeConfigInterface $scopeConfig)
     {
         $this->scopeConfig = $scopeConfig;
     }
@@ -60,7 +64,10 @@ class Config implements \Magento\Framework\View\Asset\ConfigInterface
      */
     public function isMergeCssFiles()
     {
-        return (bool)$this->scopeConfig->isSetFlag(self::XML_PATH_MERGE_CSS_FILES, ScopeInterface::SCOPE_STORE);
+        return (bool)$this->scopeConfig->isSetFlag(
+            self::XML_PATH_MERGE_CSS_FILES,
+            ScopeInterface::SCOPE_STORE
+        );
     }
 
     /**
@@ -70,7 +77,10 @@ class Config implements \Magento\Framework\View\Asset\ConfigInterface
      */
     public function isBundlingJsFiles()
     {
-        return (bool)$this->scopeConfig->isSetFlag(self::XML_PATH_JS_BUNDLING, ScopeInterface::SCOPE_STORE);
+        return (bool)$this->scopeConfig->isSetFlag(
+            self::XML_PATH_JS_BUNDLING,
+            ScopeInterface::SCOPE_STORE
+        );
     }
 
     /**
@@ -80,7 +90,10 @@ class Config implements \Magento\Framework\View\Asset\ConfigInterface
      */
     public function isMergeJsFiles()
     {
-        return (bool)$this->scopeConfig->isSetFlag(self::XML_PATH_MERGE_JS_FILES, ScopeInterface::SCOPE_STORE);
+        return (bool)$this->scopeConfig->isSetFlag(
+            self::XML_PATH_MERGE_JS_FILES,
+            ScopeInterface::SCOPE_STORE
+        );
     }
 
     /**
@@ -110,4 +123,17 @@ class Config implements \Magento\Framework\View\Asset\ConfigInterface
             ScopeInterface::SCOPE_STORE
         );
     }
+
+    /**
+     * Check whether minify of HTML is on
+     *
+     * @return bool
+     */
+    public function isMinifyHtml()
+    {
+        return (bool)$this->scopeConfig->isSetFlag(
+            self::XML_PATH_MINIFICATION_HTML,
+            ScopeInterface::SCOPE_STORE
+        );
+    }
 }
diff --git a/lib/internal/Magento/Framework/View/Asset/ConfigInterface.php b/lib/internal/Magento/Framework/View/Asset/ConfigInterface.php
index b68e6f5fe54ae2bb36919c1e1c6912da5019243f..f099082ce4442631f9690cca216309906362fe81 100644
--- a/lib/internal/Magento/Framework/View/Asset/ConfigInterface.php
+++ b/lib/internal/Magento/Framework/View/Asset/ConfigInterface.php
@@ -46,4 +46,11 @@ interface ConfigInterface
      * @return string
      */
     public function getAssetMinificationAdapter($contentType);
+
+    /**
+     * Check whether minify of HTML is on
+     *
+     * @return bool
+     */
+    public function isMinifyHtml();
 }
diff --git a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/TemplateFile.php b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/TemplateFile.php
index 656a021c8039db4e1238fa776ccde87c4a38d898..bbf4bcd58450fe37b4f36b6158e4625463cef3d4 100644
--- a/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/TemplateFile.php
+++ b/lib/internal/Magento/Framework/View/Design/FileResolution/Fallback/TemplateFile.php
@@ -7,6 +7,7 @@
 namespace Magento\Framework\View\Design\FileResolution\Fallback;
 
 use Magento\Framework\App\State;
+use Magento\Framework\View\Asset\ConfigInterface;
 use Magento\Framework\View\Design\ThemeInterface;
 use Magento\Framework\View\Template\Html\MinifierInterface;
 
@@ -25,18 +26,26 @@ class TemplateFile extends File
      */
     protected $templateMinifier;
 
+    /**
+     * @var ConfigInterface
+     */
+    protected $assetConfig;
+
     /**
      * @param ResolverInterface $resolver
      * @param MinifierInterface $templateMinifier
      * @param State $appState
+     * @param ConfigInterface $assetConfig
      */
     public function __construct(
         ResolverInterface $resolver,
         MinifierInterface $templateMinifier,
-        State $appState
+        State $appState,
+        ConfigInterface $assetConfig
     ) {
         $this->appState = $appState;
         $this->templateMinifier = $templateMinifier;
+        $this->assetConfig = $assetConfig;
         parent::__construct($resolver);
     }
 
@@ -60,16 +69,18 @@ class TemplateFile extends File
     public function getFile($area, ThemeInterface $themeModel, $file, $module = null)
     {
         $template = parent::getFile($area, $themeModel, $file, $module);
-        switch ($this->appState->getMode()) {
-            case State::MODE_PRODUCTION:
-                return $this->templateMinifier->getPathToMinified($template);
-                break;
-            case State::MODE_DEFAULT:
-                return $this->templateMinifier->getMinified($template);
-                break;
-            case State::MODE_DEVELOPER:
-                return $template;
-                break;
+
+        if ($template && $this->assetConfig->isMinifyHtml()) {
+            switch ($this->appState->getMode()) {
+                case State::MODE_PRODUCTION:
+                    return $this->templateMinifier->getPathToMinified($template);
+                case State::MODE_DEFAULT:
+                    return $this->templateMinifier->getMinified($template);
+                case State::MODE_DEVELOPER:
+                default:
+                    return $template;
+            }
         }
+        return $template;
     }
 }
diff --git a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php
index e28b1dbb5605a45846bbbc6fae4172a53a96ad58..b602da334f4fd47d67ea4fc374eb2cd0415732be 100644
--- a/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php
+++ b/lib/internal/Magento/Framework/View/Layout/GeneratorPool.php
@@ -31,21 +31,29 @@ class GeneratorPool
      */
     protected $scopeResolver;
 
+    /**
+     * @var \Psr\Log\LoggerInterface
+     */
+    protected $logger;
+
     /**
      * @param ScheduledStructure\Helper $helper
      * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
      * @param \Magento\Framework\App\ScopeResolverInterface $scopeResolver
+     * @param \Psr\Log\LoggerInterface $logger
      * @param array $generators
      */
     public function __construct(
         ScheduledStructure\Helper $helper,
         \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
         \Magento\Framework\App\ScopeResolverInterface $scopeResolver,
+        \Psr\Log\LoggerInterface $logger,
         array $generators = null
     ) {
         $this->helper = $helper;
         $this->scopeConfig = $scopeConfig;
         $this->scopeResolver = $scopeResolver;
+        $this->logger = $logger;
         $this->addGenerators($generators);
     }
 
@@ -196,8 +204,13 @@ class GeneratorPool
         if (!$alias && false === $structure->getChildId($destination, $childAlias)) {
             $alias = $childAlias;
         }
-        $structure->unsetChild($element, $alias)->setAsChild($element, $destination, $alias);
-        $structure->reorderChildElement($destination, $element, $siblingName, $isAfter);
+        $structure->unsetChild($element, $alias);
+        try {
+            $structure->setAsChild($element, $destination, $alias);
+            $structure->reorderChildElement($destination, $element, $siblingName, $isAfter);
+        } catch (\OutOfBoundsException $e) {
+            $this->logger->critical('Broken reference: '. $e->getMessage());
+        }
         return $this;
     }
 }
diff --git a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php
index 9af26b5705f77006a2e21bd33b0926c0d09478c5..9c3aba6b4ba08fc6d10bca11a1110256aea45fb9 100644
--- a/lib/internal/Magento/Framework/View/Template/Html/Minifier.php
+++ b/lib/internal/Magento/Framework/View/Template/Html/Minifier.php
@@ -52,15 +52,26 @@ class Minifier implements MinifierInterface
         'label',
         'select',
         'textarea',
+        '\?',
     ];
 
+    /**
+     * @var Filesystem\Directory\ReadInterface
+     */
+    protected $rootDirectory;
+
+    /**
+     * @var Filesystem\Directory\WriteInterface
+     */
+    protected $htmlDirectory;
+
     /**
      * @param Filesystem $filesystem
      */
     public function __construct(
         Filesystem $filesystem
     ) {
-        $this->appDirectory = $filesystem->getDirectoryRead(DirectoryList::APP);
+        $this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
         $this->htmlDirectory = $filesystem->getDirectoryWrite(DirectoryList::TEMPLATE_MINIFICATION_DIR);
     }
 
@@ -72,7 +83,8 @@ class Minifier implements MinifierInterface
      */
     public function getMinified($file)
     {
-        if (!$this->htmlDirectory->isExist($this->appDirectory->getRelativePath($file))) {
+        $file = $this->htmlDirectory->getDriver()->getRealPathSafety($file);
+        if (!$this->htmlDirectory->isExist($this->rootDirectory->getRelativePath($file))) {
             $this->minify($file);
         }
         return $this->getPathToMinified($file);
@@ -87,7 +99,7 @@ class Minifier implements MinifierInterface
     public function getPathToMinified($file)
     {
         return $this->htmlDirectory->getAbsolutePath(
-            $this->appDirectory->getRelativePath($file)
+            $this->rootDirectory->getRelativePath($file)
         );
     }
 
@@ -95,24 +107,33 @@ class Minifier implements MinifierInterface
      * Minify template file
      *
      * @param string $file
+     * @return void
      */
     public function minify($file)
     {
-        $file = $this->appDirectory->getRelativePath($file);
+        $file = $this->rootDirectory->getRelativePath($file);
         $content = preg_replace(
-            '#(?<!' . implode('|', $this->inlineHtmlTags) . ')\> \<#',
-            '><',
+            '#(?<!]]>)\s+</#',
+            '</',
             preg_replace(
-                '#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre|script)\b))*+)'
-                . '(?:<(?>textarea|pre|script)\b|\z))#',
-                ' ',
+                '#((?:<\?php\s+(?!echo)[^\?]*)\?>)\s+#',
+                '$1',
                 preg_replace(
-                    '#(?<!:)//(?!\<\!\[)(?!]]\>)[^\n\r]*#',
-                    '',
+                    '#(?<!' . implode('|', $this->inlineHtmlTags) . ')\> \<#',
+                    '><',
                     preg_replace(
-                        '#(?<!:)//[^\n\r]*(\s\?\>)#',
-                        '$1',
-                        $this->appDirectory->readFile($file)
+                        '#(?ix)(?>[^\S ]\s*|\s{2,})(?=(?:(?:[^<]++|<(?!/?(?:textarea|pre|script)\b))*+)'
+                        . '(?:<(?>textarea|pre|script)\b|\z))#',
+                        ' ',
+                        preg_replace(
+                            '#(?<!:)//(?!\s*\<\!\[)(?!\s*]]\>)[^\n\r]*#',
+                            '',
+                            preg_replace(
+                                '#(?<!:)//[^\n\r]*(\s\?\>)#',
+                                '$1',
+                                $this->rootDirectory->readFile($file)
+                            )
+                        )
                     )
                 )
             )
@@ -121,6 +142,6 @@ class Minifier implements MinifierInterface
         if (!$this->htmlDirectory->isExist()) {
             $this->htmlDirectory->create();
         }
-        $this->htmlDirectory->writeFile($file, $content);
+        $this->htmlDirectory->writeFile($file, rtrim($content));
     }
 }
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php
index 644876622074ed95b4da80934857c9c78c15d54a..359ea18c0f08e8c12c94cefbdf212bd14c415b40 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Design/FileResolution/Fallback/TemplateFileTest.php
@@ -6,10 +6,10 @@
 
 namespace Magento\Framework\View\Test\Unit\Design\FileResolution\Fallback;
 
-use \Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile;
-
 use Magento\Framework\App\State;
 use Magento\Framework\View\Design\Fallback\RulePool;
+use Magento\Framework\View\Design\FileResolution\Fallback\TemplateFile;
+use Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface;
 
 class TemplateFileTest extends \PHPUnit_Framework_TestCase
 {
@@ -33,12 +33,23 @@ class TemplateFileTest extends \PHPUnit_Framework_TestCase
      */
     protected $object;
 
+    /**
+     * @var \Magento\Framework\View\Asset\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $assetConfig;
+
     protected function setUp()
     {
         $this->resolver = $this->getMock('Magento\Framework\View\Design\FileResolution\Fallback\ResolverInterface');
         $this->minifier = $this->getMock('Magento\Framework\View\Template\Html\MinifierInterface');
         $this->state = $this->getMockBuilder('Magento\Framework\App\State')->disableOriginalConstructor()->getMock();
-        $this->object = new TemplateFile($this->resolver, $this->minifier, $this->state);
+        $this->assetConfig = $this->getMockForAbstractClass(
+            'Magento\Framework\View\Asset\ConfigInterface',
+            [],
+            '',
+            false
+        );
+        $this->object = new TemplateFile($this->resolver, $this->minifier, $this->state, $this->assetConfig);
     }
 
     /**
@@ -46,6 +57,11 @@ class TemplateFileTest extends \PHPUnit_Framework_TestCase
      */
     public function testGetFileWhenStateDeveloper()
     {
+        $this->assetConfig
+            ->expects($this->once())
+            ->method('isMinifyHtml')
+            ->willReturn(true);
+
         $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface');
         $expected = 'some/file.ext';
 
@@ -63,10 +79,17 @@ class TemplateFileTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Cover getFile when mode is default
+     * @param string $mode
+     * @param string $method
      * @dataProvider getMinifiedDataProvider
      */
     public function testGetFileWhenModifiedNeeded($mode, $method)
     {
+        $this->assetConfig
+            ->expects($this->once())
+            ->method('isMinifyHtml')
+            ->willReturn(true);
+
         $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface');
         $expected = 'some/file.ext';
         $expectedMinified = '/path/to/minified/some/file.ext';
@@ -87,6 +110,27 @@ class TemplateFileTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($expectedMinified, $actual);
     }
 
+    public function testGetFileIfMinificationIsDisabled()
+    {
+        $this->assetConfig
+            ->expects($this->once())
+            ->method('isMinifyHtml')
+            ->willReturn(false);
+
+        $theme = $this->getMockForAbstractClass('\Magento\Framework\View\Design\ThemeInterface');
+        $expected = 'some/file.ext';
+
+        $this->resolver->expects($this->once())
+            ->method('resolve')
+            ->with(RulePool::TYPE_TEMPLATE_FILE, 'file.ext', 'frontend', $theme, null, 'Magento_Module')
+            ->will($this->returnValue($expected));
+
+        $this->state->expects($this->never())->method('getMode');
+
+        $actual = $this->object->getFile('frontend', $theme, 'file.ext', 'Magento_Module');
+        $this->assertSame($expected, $actual);
+    }
+
     /**
      * Contain different methods by mode for HTML minification
      *
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php
index f9c272ffaf9df7bd35ebdaf49e15023f09fbeeb9..154ff37e00f0a408aa602dd7cfcac1eaf42c07d6 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/GeneratorPoolTest.php
@@ -39,21 +39,14 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase
      */
     protected $structureMock;
 
-    /**
-     * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $scopeConfigMock;
-
-    /**
-     * @var \Magento\Framework\App\ScopeResolverInterface|\PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $scopeResolverMock;
-
     /**
      * @var GeneratorPool
      */
     protected $model;
 
+    /**
+     * @return void
+     */
     protected function setUp()
     {
         // ScheduledStructure
@@ -79,18 +72,13 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
 
-        $this->scopeConfigMock = $this->getMockBuilder('Magento\Framework\App\Config\ScopeConfigInterface')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $this->scopeResolverMock = $this->getMockBuilder('Magento\Framework\App\ScopeResolverInterface')
-            ->disableOriginalConstructor()
-            ->getMock();
-
-        $this->model = new GeneratorPool(
-            $this->helperMock,
-            $this->scopeConfigMock,
-            $this->scopeResolverMock,
-            $this->getGeneratorsMocks()
+        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+        $this->model = $helper->getObject(
+            'Magento\Framework\View\Layout\GeneratorPool',
+            [
+                'helper' => $this->helperMock,
+                'generators' => $this->getGeneratorsMocks()
+            ]
         );
     }
 
@@ -110,6 +98,9 @@ class GeneratorPoolTest extends \PHPUnit_Framework_TestCase
     }
 
     /**
+     * @param array $schedule
+     * @param array $expectedSchedule
+     * @return void
      * @dataProvider processDataProvider
      */
     public function testProcess($schedule, $expectedSchedule)
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php
index 20c3d33358cd872d4f0904394478e750283ca990..a93962b3ae7e689f4ef943e5273b9da9afd8cffc 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Template/Html/MinifierTest.php
@@ -6,9 +6,8 @@
 
 namespace Magento\Framework\View\Test\Unit\Template\Html;
 
-use \Magento\Framework\View\Template\Html\Minifier;
-
 use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\View\Template\Html\Minifier;
 
 class MinifierTest extends \PHPUnit_Framework_TestCase
 {
@@ -39,7 +38,7 @@ class MinifierTest extends \PHPUnit_Framework_TestCase
 
         $filesystem->expects($this->once())
             ->method('getDirectoryRead')
-            ->with(DirectoryList::APP)
+            ->with(DirectoryList::ROOT)
             ->willReturn($this->appDirectory);
         $filesystem->expects($this->once())
             ->method('getDirectoryWrite')
@@ -72,6 +71,7 @@ class MinifierTest extends \PHPUnit_Framework_TestCase
         $this->assertEquals($absolutePath, $this->object->getPathToMinified($file));
     }
 
+    // @codingStandardsIgnoreStart
     /**
      * Covered method minify and test regular expressions
      * @test
@@ -115,8 +115,9 @@ class MinifierTest extends \PHPUnit_Framework_TestCase
     </body>
 </html>
 TEXT;
+
         $expectedContent = <<<TEXT
-<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ ?><?php ?><html><head><title>Test title</title></head><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?php echo \$block->someMethod(); ?><div style="width: 800px" class="<?php echo \$block->getClass() ?>" /><script>
+<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ ?><?php ?><html><head><title>Test title</title></head><body><a href="http://somelink.com/text.html">Text Link</a> <img src="test.png" alt="some text" /><?php echo \$block->someMethod(); ?> <div style="width: 800px" class="<?php echo \$block->getClass() ?>" /><script>
             //<![CDATA[
             var someVar = 123;
             testFunctionCall(function () {
@@ -128,7 +129,7 @@ TEXT;
                 }
             });
             //]]>
-        </script><?php echo "http://some.link.com/" ?><em>inline text</em> </body></html>
+</script><?php echo "http://some.link.com/" ?> <em>inline text</em></body></html>
 TEXT;
 
         $this->appDirectory->expects($this->once())
@@ -151,6 +152,7 @@ TEXT;
 
         $this->object->minify($file);
     }
+    // @codingStandardsIgnoreEnd
 
     /**
      * Contain method modify and getPathToModified
@@ -161,15 +163,28 @@ TEXT;
         $file = '/absolute/path/to/phtml/template/file';
         $relativePath = 'relative/path/to/phtml/template/file';
 
-        $this->appDirectory->expects($this->at(0))
+        $htmlDriver = $this->getMock('Magento\Framework\Filesystem\DriverInterface', [], [], '', false);
+        $htmlDriver
+            ->expects($this->once())
+            ->method('getRealPathSafety')
+            ->willReturn($file);
+
+        $this->appDirectory
+            ->expects($this->exactly(3))
             ->method('getRelativePath')
             ->with($file)
             ->willReturn($relativePath);
-        $this->htmlDirectory->expects($this->at(0))
+        $this->htmlDirectory
+            ->expects($this->at(1))
             ->method('isExist')
             ->with($relativePath)
             ->willReturn(false);
 
+        $this->htmlDirectory
+            ->expects($this->once())
+            ->method('getDriver')
+            ->willReturn($htmlDriver);
+
         $this->object->getMinified($file);
     }
 }
diff --git a/lib/internal/Magento/Framework/Webapi/Exception.php b/lib/internal/Magento/Framework/Webapi/Exception.php
index 130819e29ef5af8d5c64b1071b73403842788595..b5b46c0e562bcf5aaebc986c7ecc7164380f93e7 100644
--- a/lib/internal/Magento/Framework/Webapi/Exception.php
+++ b/lib/internal/Magento/Framework/Webapi/Exception.php
@@ -67,7 +67,7 @@ class Exception extends \RuntimeException
     /**
      * List of errors
      *
-     * @var null|ErrorMessage[]
+     * @var null|\Magento\Framework\Exception\LocalizedException[]
      */
     protected $_errors;
 
@@ -79,7 +79,7 @@ class Exception extends \RuntimeException
      * @param int $httpCode
      * @param array $details Additional exception details
      * @param string $name Exception name
-     * @param ErrorMessage[]|null $errors Array of errors messages
+     * @param \Magento\Framework\Exception\LocalizedException[]|null $errors Array of errors messages
      * @param string $stackTrace
      *
      * @throws \InvalidArgumentException
@@ -148,7 +148,7 @@ class Exception extends \RuntimeException
     /**
      * Retrieve list of errors.
      *
-     * @return null|ErrorMessage[]
+     * @return null|\Magento\Framework\Exception\LocalizedException[]
      */
     public function getErrors()
     {
diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request.php b/lib/internal/Magento/Framework/Webapi/Rest/Request.php
index 9f97855cb7a897eb75a7c9b0a4568c3209541842..49989a9a0995e1b33101b74e3ec017c9709824b3 100644
--- a/lib/internal/Magento/Framework/Webapi/Rest/Request.php
+++ b/lib/internal/Magento/Framework/Webapi/Rest/Request.php
@@ -9,6 +9,7 @@
 namespace Magento\Framework\Webapi\Rest;
 
 use Magento\Framework\Api\SimpleDataObjectConverter;
+use Magento\Framework\Phrase;
 
 class Request extends \Magento\Framework\Webapi\Request
 {
@@ -131,21 +132,21 @@ class Request extends \Magento\Framework\Webapi\Request
      * Get Content-Type of request.
      *
      * @return string
-     * @throws \Magento\Framework\Webapi\Exception
+     * @throws \Magento\Framework\Exception\InputException
      */
     public function getContentType()
     {
         $headerValue = $this->getHeader('Content-Type');
 
         if (!$headerValue) {
-            throw new \Magento\Framework\Exception\InputException('Content-Type header is empty.');
+            throw new \Magento\Framework\Exception\InputException(new Phrase('Content-Type header is empty.'));
         }
         if (!preg_match('~^([a-z\d/\-+.]+)(?:; *charset=(.+))?$~Ui', $headerValue, $matches)) {
-            throw new \Magento\Framework\Exception\InputException('Content-Type header is invalid.');
+            throw new \Magento\Framework\Exception\InputException(new Phrase('Content-Type header is invalid.'));
         }
         // request encoding check if it is specified in header
         if (isset($matches[2]) && self::REQUEST_CHARSET != strtolower($matches[2])) {
-            throw new \Magento\Framework\Exception\InputException('UTF-8 is the only supported charset.');
+            throw new \Magento\Framework\Exception\InputException(new Phrase('UTF-8 is the only supported charset.'));
         }
 
         return $matches[1];
@@ -155,12 +156,12 @@ class Request extends \Magento\Framework\Webapi\Request
      * Retrieve current HTTP method.
      *
      * @return string
-     * @throws \Magento\Framework\Webapi\Exception
+     * @throws \Magento\Framework\Exception\InputException
      */
     public function getHttpMethod()
     {
         if (!$this->isGet() && !$this->isPost() && !$this->isPut() && !$this->isDelete()) {
-            throw new \Magento\Framework\Exception\InputException('Request method is invalid.');
+            throw new \Magento\Framework\Exception\InputException(new Phrase('Request method is invalid.'));
         }
         return $this->getMethod();
     }
diff --git a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php
index 2298ea27fdfc6c08ef9d69e37981b2fc3d9d7cc1..75d2a77d1cbd91cb954174264f64c699099f1c2b 100644
--- a/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php
+++ b/lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php
@@ -17,6 +17,7 @@ use Magento\Framework\Exception\SerializationException;
 use Magento\Framework\Reflection\TypeProcessor;
 use Magento\Framework\ObjectManagerInterface;
 use Magento\Framework\Webapi\Exception as WebapiException;
+use Magento\Framework\Phrase;
 use Zend\Code\Reflection\ClassReflection;
 use Zend\Code\Reflection\MethodReflection;
 use Zend\Code\Reflection\ParameterReflection;
@@ -110,7 +111,7 @@ class ServiceInputProcessor
         if (!empty($inputError)) {
             $exception = new InputException();
             foreach ($inputError as $errorParamField) {
-                $exception->addError(InputException::REQUIRED_FIELD, ['fieldName' => $errorParamField]);
+                $exception->addError(new Phrase(InputException::REQUIRED_FIELD, ['fieldName' => $errorParamField]));
             }
             if ($exception->wasErrorAdded()) {
                 throw $exception;
diff --git a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php
index 29026d8312658633a1f12c7c06257ece73e254fe..ab378a49c0bdfbfb68ddc350d653a475bcfc2445 100644
--- a/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php
+++ b/lib/internal/Magento/Framework/Webapi/Test/Unit/ErrorProcessorTest.php
@@ -12,6 +12,7 @@ use \Magento\Framework\Webapi\ErrorProcessor;
 use Magento\Framework\Exception\AuthorizationException;
 use Magento\Framework\Exception\NoSuchEntityException;
 use Magento\Framework\Webapi\Exception as WebapiException;
+use Magento\Framework\Phrase;
 
 class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 {
@@ -66,6 +67,8 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test render method in JSON format.
+     *
+     * @return void
      */
     public function testRenderJson()
     {
@@ -93,7 +96,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
      *
      * Method encodes data to JSON and returns it.
      *
-     * @param $data
+     * @param array $data
      * @return string
      */
     public function callbackJsonEncode($data)
@@ -103,6 +106,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test render method in JSON format with turned on developer mode.
+     * @return void
      */
     public function testRenderJsonInDeveloperMode()
     {
@@ -127,6 +131,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test render method in XML format.
+     * @return void
      */
     public function testRenderXml()
     {
@@ -144,6 +149,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test render method in XML format with turned on developer mode.
+     * @return void
      */
     public function testRenderXmlInDeveloperMode()
     {
@@ -164,6 +170,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test default render format is JSON.
+     * @return void
      */
     public function testRenderDefaultFormat()
     {
@@ -176,6 +183,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
 
     /**
      * Test maskException method with turned on developer mode.
+     * @return void
      */
     public function testMaskExceptionInDeveloperMode()
     {
@@ -197,6 +205,11 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
     /**
      * Test sendResponse method with various exceptions
      *
+     * @param \Exception $exception
+     * @param int $expectedHttpCode
+     * @param string $expectedMessage
+     * @param array $expectedDetails
+     * @return void
      * @dataProvider dataProviderForSendResponseExceptions
      */
     public function testMaskException($exception, $expectedHttpCode, $expectedMessage, $expectedDetails)
@@ -212,18 +225,23 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    /**
+     * @return array
+     */
     public function dataProviderForSendResponseExceptions()
     {
         return [
             'NoSuchEntityException' => [
                 new NoSuchEntityException(
-                    NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
-                    [
-                        'fieldName' => 'detail1',
-                        'fieldValue' => 'value1',
-                        'field2Name' => 'resource_id',
-                        'field2Value' => 'resource10',
-                    ]
+                    new Phrase(
+                        NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
+                        [
+                            'fieldName' => 'detail1',
+                            'fieldValue' => 'value1',
+                            'field2Name' => 'resource_id',
+                            'field2Value' => 'resource10',
+                        ]
+                    )
                 ),
                 \Magento\Framework\Webapi\Exception::HTTP_NOT_FOUND,
                 NoSuchEntityException::MESSAGE_DOUBLE_FIELDS,
@@ -242,8 +260,10 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
             ],
             'AuthorizationException' => [
                 new AuthorizationException(
-                    AuthorizationException::NOT_AUTHORIZED,
-                    ['consumer_id' => '3', 'resources' => '4']
+                    new Phrase(
+                        AuthorizationException::NOT_AUTHORIZED,
+                        ['consumer_id' => '3', 'resources' => '4']
+                    )
                 ),
                 WebapiException::HTTP_UNAUTHORIZED,
                 AuthorizationException::NOT_AUTHORIZED,
@@ -265,6 +285,7 @@ class ErrorProcessorTest extends \PHPUnit_Framework_TestCase
      * @param int $expectedHttpCode
      * @param string $expectedMessage
      * @param array $expectedDetails
+     * @return void
      */
     public function assertMaskedException(
         $maskedException,
diff --git a/pub/static/.htaccess b/pub/static/.htaccess
index 8d1f4ff8630b1e68d3011c6b2a3c80d4bedb4644..c96881a49c63ff713f87d9148f6f8c5816ecfeb8 100755
--- a/pub/static/.htaccess
+++ b/pub/static/.htaccess
@@ -1,6 +1,10 @@
 <IfModule mod_php5.c>
 php_flag engine 0
 </IfModule>
+
+# To avoid situation when web server automatically adds extension to path
+Options -MultiViews
+
 <IfModule mod_rewrite.c>
     RewriteEngine On