diff --git a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Factory.php b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Factory.php
index 5cb02fb70512a02174cb60e6145c3095d0ba85af..623342951516a038acd8ae5beeb51081d53a491f 100644
--- a/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Factory.php
+++ b/app/code/Magento/Config/Block/System/Config/Form/Fieldset/Factory.php
@@ -7,7 +7,7 @@
 namespace Magento\Config\Block\System\Config\Form\Fieldset;
 
 /**
- * Magento\Config\Block\System\Config\Form\Fieldset object factory
+ * Magento\Config\Block\System\Config\Form\Fieldset Class Factory
  *
  * @codeCoverageIgnore
  */
diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..3f8b7596fd4a541eebe52c9f8e30168dc48b35ee
--- /dev/null
+++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/DwstreeTest.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ * Copyright © 2015 Magento. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+namespace Magento\Config\Test\Unit\Block\System\Config;
+
+class DwstreeTest extends \PHPUnit_Framework_TestCase
+{
+    /**
+     * @var \Magento\Config\Block\System\Config\Dwstree
+     */
+    protected $object;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $requestMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeManagerMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $websiteMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $storeMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $context;
+
+    protected function setUp()
+    {
+        $this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->websiteMock = $this->getMockBuilder('Magento\Store\Model\Website')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->storeMock = $this->getMockBuilder('Magento\Store\Model\Store')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+
+        $this->context = $objectManager->getObject(
+            'Magento\Backend\Block\Template\Context',
+            [
+                'request'      => $this->requestMock,
+                'storeManager' => $this->storeManagerMock,
+            ]
+        );
+
+        $this->object = $objectManager->getObject(
+            'Magento\Config\Block\System\Config\Dwstree',
+            ['context' => $this->context]
+        );
+    }
+
+    /**
+     * @param $section
+     * @param $website
+     * @param $store
+     * @dataProvider initTabsDataProvider
+     */
+    public function testInitTabs($section, $website, $store)
+    {
+        $this->requestMock->expects($this->any())
+            ->method('getParam')
+            ->will(
+                $this->returnValueMap(
+                    [
+                        ['section', $section],
+                        ['website', $website['expected']['code']],
+                        ['store', $store['expected']['code']],
+                    ]
+                )
+            );
+        $this->storeManagerMock->expects($this->once())
+            ->method('getWebsites')
+            ->willReturn([$this->websiteMock]);
+        $this->websiteMock->expects($this->any())
+            ->method('getCode')
+            ->willReturn($website['actual']['code']);
+        $this->websiteMock->expects($this->any())
+            ->method('getName')
+            ->willReturn($website['expected']['name']);
+        $this->websiteMock->expects($this->once())
+            ->method('getStores')
+            ->willReturn([$this->storeMock]);
+        $this->storeMock->expects($this->any())
+            ->method('getCode')
+            ->willReturn($store['actual']['code']);
+        $this->storeMock->expects($this->any())
+            ->method('getName')
+            ->willReturn($store['actual']['name']);
+
+        $this->assertEquals($this->object, $this->object->initTabs());
+
+        $this->assertEquals(
+            [
+                'default',
+                'website_' . $website['actual']['code'],
+                'store_'   . $store['actual']['code']
+            ],
+            $this->object->getTabsIds()
+        );
+    }
+
+    public function initTabsDataProvider()
+    {
+        return [
+            'matchAll'  => [
+                'scope'   => 'Test Scope',
+                'website' => [
+                    'expected' => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                    'actual'   => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                ],
+                'store'   => [
+                    'expected' => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                    'actual'   => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                ],
+            ],
+            'matchStore'  => [
+                'scope'   => 'Test Scope',
+                'website' => [
+                    'expected' => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                    'actual'   => ['name' => false, 'code' => false],
+                ],
+                'store'   => [
+                    'expected' => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                    'actual'   => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                ],
+            ],
+            'matchWebsite'  => [
+                'scope'   => 'Test Scope',
+                'website' => [
+                    'expected' => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                    'actual'   => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                ],
+                'store'   => [
+                    'expected' => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                    'actual'   => ['name' => false, 'code' => false],
+                ],
+            ],
+            'noMatch'  => [
+                'scope'   => 'Test Scope',
+                'website' => [
+                    'expected' => ['name' => 'Test Website Name', 'code' => 'Test Website Code'],
+                    'actual'   => ['name' => false, 'code' => false],
+                ],
+                'store'   => [
+                    'expected' => ['name' => 'Test   Store Name', 'code' => 'Test   Store Code'],
+                    'actual'   => ['name' => false, 'code' => false],
+                ],
+            ],
+        ];
+    }
+}
diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php
index 11ae924fe7ac294734c7ce67feffd2417a8b9bb4..323ec70a02c9d0daf2e43d290750ce3e64b8acd2 100644
--- a/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php
+++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/EditTest.php
@@ -145,4 +145,43 @@ class EditTest extends \PHPUnit_Framework_TestCase
 
         $this->assertEquals($expectedUrl, $this->_object->getSaveUrl());
     }
+
+    public function testPrepareLayout()
+    {
+        $expectedHeader = 'Test Header';
+        $expectedLabel  = 'Test  Label';
+        $expectedBlock  = 'Test  Block';
+
+        $blockMock = $this->getMockBuilder('Magento\Framework\View\Element\Template')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->_sectionMock->expects($this->once())
+            ->method('getFrontendModel')
+            ->willReturn($expectedBlock);
+        $this->_sectionMock->expects($this->once())
+            ->method('getLabel')
+            ->willReturn($expectedLabel);
+        $this->_sectionMock->expects($this->once())
+            ->method('getHeaderCss')
+            ->willReturn($expectedHeader);
+        $this->_layoutMock->expects($this->once())
+            ->method('getBlock')
+            ->with('page.actions.toolbar')
+            ->willReturn($blockMock);
+        $this->_layoutMock->expects($this->once())
+            ->method('createBlock')
+            ->with($expectedBlock)
+            ->willReturn($blockMock);
+        $blockMock->expects($this->once())
+            ->method('getNameInLayout')
+            ->willReturn($expectedBlock);
+        $this->_layoutMock->expects($this->once())
+            ->method('setChild')
+            ->with($expectedBlock, $expectedBlock, 'form')
+            ->willReturn($this->_layoutMock);
+
+        $this->_object->setNameInLayout($expectedBlock);
+        $this->_object->setLayout($this->_layoutMock);
+    }
 }
diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php
index 2c7125e9748104e156d1e0ae6b383b65b5502700..4e3579dde64ca8791c2e9c2cbd8a2ad550b9e896 100644
--- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php
+++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldTest.php
@@ -71,7 +71,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
                 'getInherit',
                 'getCanUseWebsiteValue',
                 'getCanUseDefaultValue',
-                'setDisabled'
+                'setDisabled',
+                'getTooltip',
             ],
             [],
             '',
@@ -140,6 +141,19 @@ class FieldTest extends \PHPUnit_Framework_TestCase
         $this->assertContains($expected, $actual);
     }
 
+    public function testRenderValueWithTooltipBlock()
+    {
+        $testTooltip = 'test_tooltip';
+        $this->_elementMock->expects($this->any())->method('getTooltip')->will($this->returnValue($testTooltip));
+        $expected = '<td class="value with-tooltip">' .
+            $this->_testData['elementHTML'] .
+            '<div class="tooltip"><span class="help"><span></span></span><div class="tooltip-content">' .
+            $testTooltip .
+            '</div></div></td>';
+        $actual = $this->_object->render($this->_elementMock);
+        $this->assertContains($expected, $actual);
+    }
+
     public function testRenderHint()
     {
         $testHint = 'test_hint';
diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php
index 6f5fa46f65a237ea26bf676537d91aac3c6d4ade..10fc39366922c25b5d2b295ad8ef1a30ba8efecf 100644
--- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php
+++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Fieldset/Modules/DisableOutputTest.php
@@ -7,102 +7,236 @@ namespace Magento\Config\Test\Unit\Block\System\Config\Form\Fieldset\Modules;
 
 class DisableOutputTest extends \PHPUnit_Framework_TestCase
 {
-    public function testRender()
+    /**
+     * @var \Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput
+     */
+    protected $object;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $elementMock;
+
+    /**
+     * @var array
+     */
+    protected $elementData = [
+        'htmlId'      => 'test_field_id',
+        'name'        => 'test_name',
+        'label'       => 'test_label',
+        'elementHTML' => 'test_html',
+        'legend'      => 'test_legend',
+        'comment'     => 'test_comment',
+        'tooltip'     => 'test_tooltip',
+    ];
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $layoutMock;
+
+    /**
+     * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
+     */
+    protected $objectManager;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $moduleListMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $authSessionMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $userMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $jsHelperMock;
+
+    /**
+     * @return void
+     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+     */
+    protected function setUp()
     {
-        $testData = [
-            'htmlId' => 'test_field_id',
-            'label' => 'test_label',
-            'elementHTML' => 'test_html',
-            'legend' => 'test_legend',
-            'comment' => 'test_comment',
-        ];
-
-        $testModuleList = [
-            'testModuleWithConfigData',
-            'testModuleNoConfigData',
-        ];
+        $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
 
-        $configData = ['advanced/modules_disable_output/testModuleWithConfigData' => 'testModuleData'];
-
-        $fieldMock = $this->getMockBuilder('Magento\Config\Block\System\Config\Form\Field')
+        $rendererMock = $this->getMockBuilder('Magento\Config\Block\System\Config\Form\Field')
             ->disableOriginalConstructor()
             ->getMock();
 
-        $layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
+        $this->layoutMock = $this->getMockBuilder('Magento\Framework\View\Layout')
             ->disableOriginalConstructor()
             ->getMock();
-        $layoutMock->expects($this->once())
+        $this->layoutMock->expects($this->any())
             ->method('getBlockSingleton')
-            ->with('Magento\Config\Block\System\Config\Form\Field')
-            ->willReturn($fieldMock);
+            ->willReturn($rendererMock);
 
-        $groupMock = $this->getMockBuilder('Magento\Config\Model\Config\Structure\Element\Group')
+        $this->jsHelperMock = $this->getMockBuilder('Magento\Framework\View\Helper\Js')
             ->disableOriginalConstructor()
             ->getMock();
-        $groupMock->expects($this->once())->method('getFieldsetCss')->willReturn('test_fieldset_css');
 
-        $elementMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Text')
+        $this->moduleListMock = $this->getMockBuilder('Magento\Framework\Module\ModuleListInterface')
+            ->setMethods(['getNames', 'has', 'getAll', 'getOne'])
             ->disableOriginalConstructor()
-            ->setMethods(
-                [
-                    'getHtmlId', 'getExpanded', 'getElements', 'getLegend',
-                    'getComment', 'addField', 'setRenderer', 'toHtml'
-                ]
-            )->getMock();
+            ->getMock();
 
-        $elementMock->expects($this->any())
-            ->method('getHtmlId')
-            ->willReturn($testData['htmlId']);
+        $this->moduleListMock->expects($this->any())
+            ->method('getNames')
+            ->will($this->returnValue(['Test Name']));
+        $this->moduleListMock->expects($this->any())
+            ->method('has')
+            ->will($this->returnValue(true));
+        $this->moduleListMock->expects($this->any())
+            ->method('getAll')
+            ->will($this->returnValue([]));
+        $this->moduleListMock->expects($this->any())
+            ->method('getOne')
+            ->will($this->returnValue(null));
+
+        $this->authSessionMock = $this->getMockBuilder('Magento\Backend\Model\Auth\Session')
+            ->setMethods(['getUser'])
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->userMock = $this->getMockBuilder('Magento\User\Model\User')
+            ->setMethods(['getExtra'])
+            ->disableOriginalConstructor()
+            ->getMock();
 
-        $elementMock->expects($this->any())->method('getExpanded')->willReturn(true);
-        $elementMock->expects($this->any())->method('getLegend')->willReturn($testData['legend']);
-        $elementMock->expects($this->any())->method('getComment')->willReturn($testData['comment']);
-        $elementMock->expects($this->any())->method('addField')->willReturn($elementMock);
-        $elementMock->expects($this->any())->method('setRenderer')->willReturn($elementMock);
-        $elementMock->expects($this->any())->method('toHtml')->willReturn('test_element_html');
+        $this->authSessionMock->expects($this->any())
+            ->method('getUser')
+            ->willReturn($this->userMock);
 
-        $moduleListMock = $this->getMockBuilder('Magento\Framework\Module\ModuleList')
+        $groupMock = $this->getMockBuilder('Magento\Config\Model\Config\Structure\Element\Group')
+            ->setMethods(['getFieldsetCss'])
             ->disableOriginalConstructor()
             ->getMock();
-        $moduleListMock->expects($this->any())->method('getNames')->willReturn(
-            array_merge(['Magento_Backend'], $testModuleList)
-        );
+        $groupMock->expects($this->any())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css'));
 
         $factory = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Factory')
             ->disableOriginalConstructor()
             ->getMock();
-
         $factoryColl = $this->getMockBuilder('Magento\Framework\Data\Form\Element\CollectionFactory')
             ->disableOriginalConstructor()
             ->getMock();
+        $formMock = $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [$factory, $factoryColl]);
 
-        $formMock = $this->getMockBuilder('Magento\Framework\Data\Form\AbstractForm')
-            ->disableOriginalConstructor()
-            ->setConstructorArgs([$factory, $factoryColl])
-            ->getMock();
+        $context = $this->objectManager->getObject(
+            'Magento\Backend\Block\Context',
+            [
+                'layout' => $this->layoutMock,
+            ]
+        );
 
-        $formMock->expects($this->any())->method('getConfigValue')->willReturn('testConfigData');
+        $data = [
+            'context'     => $context,
+            'authSession' => $this->authSessionMock,
+            'jsHelper'    => $this->jsHelperMock,
+            'moduleList'  => $this->moduleListMock,
+            'data' => [
+                'group'          => $groupMock,
+                'form'           => $formMock,
+            ],
+        ];
 
-        $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
-        $object = $objectManager->getObject(
+        $this->object = $this->objectManager->getObject(
             'Magento\Config\Block\System\Config\Form\Fieldset\Modules\DisableOutput',
-            [
-                'moduleList' => $moduleListMock,
-                'layout' => $layoutMock,
-                'data' => [
-                    'group'      => $groupMock,
-                    'form'       => $formMock,
-                    'config_data' => $configData,
-                ],
-            ]
+            $data
         );
 
-        $collection = $objectManager->getObject('Magento\Framework\Data\Form\Element\Collection');
-        $elementMock->expects($this->any())->method('getElements')->willReturn($collection);
+        $this->elementMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Text')
+            ->setMethods(
+                [
+                    'getId', 'getHtmlId', 'getName', 'getExpanded', 'getLegend', 'getComment', 'getTooltip', 'toHtml',
+                    'addField', 'setRenderer', 'getElements', 'getIsNested'
+                ]
+            )
+            ->disableOriginalConstructor()
+            ->disableOriginalClone()
+            ->enableAutoload()
+            ->getMock();
 
-        $actualHtml = $object->render($elementMock);
-        $this->assertContains('test_element_html', $actualHtml);
-        $this->assertContains('test_field_id', $actualHtml);
-        $this->assertContains('test_comment', $actualHtml);
+        $this->elementMock->expects($this->any())
+            ->method('getId')
+            ->will($this->returnValue($this->elementData['htmlId']));
+        $this->elementMock->expects($this->any())
+            ->method('getHtmlId')
+            ->will($this->returnValue($this->elementData['htmlId']));
+        $this->elementMock->expects($this->any())
+            ->method('getName')
+            ->will($this->returnValue($this->elementData['name']));
+        $this->elementMock->expects($this->any())
+            ->method('getLegend')
+            ->will($this->returnValue($this->elementData['legend']));
+        $this->elementMock->expects($this->any())
+            ->method('getComment')
+            ->will($this->returnValue($this->elementData['comment']));
+        $this->elementMock->expects($this->any())
+            ->method('getTooltip')
+            ->will($this->returnValue($this->elementData['tooltip']));
+        $this->elementMock->expects($this->any())
+            ->method('toHtml')
+            ->will($this->returnValue($this->elementData['elementHTML']));
+        $this->elementMock->expects($this->any())
+            ->method('addField')
+            ->will($this->returnValue($this->elementMock));
+        $this->elementMock->expects($this->any())
+            ->method('setRenderer')
+            ->will($this->returnValue($this->elementMock));
+        $this->elementMock->expects($this->any())
+            ->method('getElements')
+            ->will($this->returnValue([$this->elementMock]));
+    }
+
+    /**
+     * @param $expanded
+     * @param $nested
+     * @param $extra
+     * @dataProvider renderDataProvider
+     */
+    public function testRender($expanded, $nested, $extra)
+    {
+        $this->elementMock->expects($this->any())->method('getExpanded')->will($this->returnValue($expanded));
+        $this->elementMock->expects($this->any())->method('getIsNested')->will($this->returnValue($nested));
+        $this->userMock->expects($this->any())->method('getExtra')->willReturn($extra);
+        $actualHtml = $this->object->render($this->elementMock);
+
+        $this->assertContains($this->elementData['htmlId'], $actualHtml);
+        $this->assertContains($this->elementData['legend'], $actualHtml);
+        $this->assertContains($this->elementData['comment'], $actualHtml);
+        $this->assertContains($this->elementData['tooltip'], $actualHtml);
+        $this->assertContains($this->elementData['elementHTML'], $actualHtml);
+        if ($nested) {
+            $this->assertContains('nested', $actualHtml);
+        }
+    }
+
+    public function renderDataProvider()
+    {
+        return [
+            'expandedNestedExtra' => [
+                'expanded' => true,
+                'nested'   => true,
+                'extra'    => [],
+            ],
+            'collapsedNotNestedExtra' => [
+                'expanded' => false,
+                'nested'   => false,
+                'extra'    => ['configState' => [$this->elementData['htmlId'] => true]],
+            ],
+            'collapsedNotNestedNoExtra' => [
+                'expanded' => false,
+                'nested'   => false,
+                'extra'    => [],
+            ],
+        ];
     }
 }
diff --git a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php
index ec6521ec090ac75e2c0442e06fecd77eb4742b04..e1d4f266467e194a77f43539f0eba25c647ae5c7 100644
--- a/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php
+++ b/app/code/Magento/Config/Test/Unit/Block/System/Config/Form/FieldsetTest.php
@@ -30,7 +30,15 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
     /**
      * @var array
      */
-    protected $_testData;
+    protected $testData = [
+        'htmlId' => 'test_field_id',
+        'name' => 'test_name',
+        'label' => 'test_label',
+        'elementHTML' => 'test_html',
+        'legend' => 'test_legend',
+        'comment' => 'test_comment',
+        'tooltip'     => 'test_tooltip',
+    ];
 
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject
@@ -47,16 +55,42 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
      */
     protected $_helperMock;
 
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $authSessionMock;
+
+    /**
+     * @var \PHPUnit_Framework_MockObject_MockObject
+     */
+    protected $userMock;
+
+    /**
+     * @return void
+     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+     */
     protected function setUp()
     {
-        $this->_requestMock = $this->getMock(
-            'Magento\Framework\App\RequestInterface',
-            [],
-            [],
-            '',
-            false,
-            false
-        );
+        $this->authSessionMock = $this->getMockBuilder('Magento\Backend\Model\Auth\Session')
+            ->setMethods(['getUser'])
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->userMock = $this->getMockBuilder('Magento\User\Model\User')
+            ->setMethods(['getExtra'])
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $this->authSessionMock->expects($this->any())
+            ->method('getUser')
+            ->willReturn($this->userMock);
+
+        $this->_requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->_requestMock->expects($this->any())
+            ->method('getParam')
+            ->willReturn('Test Param');
         $this->_urlModelMock = $this->getMock('Magento\Backend\Model\Url', [], [], '', false, false);
         $this->_layoutMock = $this->getMock('Magento\Framework\View\Layout', [], [], '', false, false);
         $groupMock = $this->getMock(
@@ -66,12 +100,13 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
-        $groupMock->expects($this->once())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css'));
+        $groupMock->expects($this->any())->method('getFieldsetCss')->will($this->returnValue('test_fieldset_css'));
 
         $this->_helperMock = $this->getMock('Magento\Framework\View\Helper\Js', [], [], '', false, false);
 
         $data = [
             'request' => $this->_requestMock,
+            'authSession' => $this->authSessionMock,
             'urlBuilder' => $this->_urlModelMock,
             'layout' => $this->_layoutMock,
             'jsHelper' => $this->_helperMock,
@@ -80,18 +115,9 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
         $this->_testHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
         $this->_object = $this->_testHelper->getObject('Magento\Config\Block\System\Config\Form\Fieldset', $data);
 
-        $this->_testData = [
-            'htmlId' => 'test_field_id',
-            'name' => 'test_name',
-            'label' => 'test_label',
-            'elementHTML' => 'test_html',
-            'legend' => 'test_legend',
-            'comment' => 'test_comment',
-        ];
-
         $this->_elementMock = $this->getMock(
             'Magento\Framework\Data\Form\Element\Text',
-            ['getHtmlId', 'getName', 'getExpanded', 'getElements', 'getLegend', 'getComment'],
+            ['getId', 'getHtmlId', 'getName', 'getElements', 'getLegend', 'getComment', 'getIsNested', 'getExpanded'],
             [],
             '',
             false,
@@ -99,67 +125,75 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
             true
         );
 
-        $this->_elementMock->expects(
-            $this->any()
-        )->method(
-            'getHtmlId'
-        )->will(
-            $this->returnValue($this->_testData['htmlId'])
-        );
-        $this->_elementMock->expects(
-            $this->any()
-        )->method(
-            'getName'
-        )->will(
-            $this->returnValue($this->_testData['name'])
-        );
-        $this->_elementMock->expects($this->any())->method('getExpanded')->will($this->returnValue(true));
-        $this->_elementMock->expects(
-            $this->any()
-        )->method(
-            'getLegend'
-        )->will(
-            $this->returnValue($this->_testData['legend'])
-        );
-        $this->_elementMock->expects(
-            $this->any()
-        )->method(
-            'getComment'
-        )->will(
-            $this->returnValue($this->_testData['comment'])
-        );
+        $this->_elementMock->expects($this->any())
+            ->method('getId')
+            ->will($this->returnValue($this->testData['htmlId']));
+        $this->_elementMock->expects($this->any())
+            ->method('getHtmlId')
+            ->will($this->returnValue($this->testData['htmlId']));
+        $this->_elementMock->expects($this->any())
+            ->method('getName')
+            ->will($this->returnValue($this->testData['name']));
+        $this->_elementMock->expects($this->any())
+            ->method('getLegend')
+            ->will($this->returnValue($this->testData['legend']));
+        $this->_elementMock->expects($this->any())
+            ->method('getComment')
+            ->will($this->returnValue($this->testData['comment']));
     }
 
-    public function testRenderWithoutStoredElements()
+    /**
+     * @param $expanded
+     * @param $nested
+     * @param extra
+     * @dataProvider testRenderWithoutStoredElementsDataProvider
+     */
+    public function testRenderWithoutStoredElements($expanded, $nested, $extra)
     {
+        $this->userMock->expects($this->any())->method('getExtra')->willReturn($extra);
         $collection = $this->_testHelper->getObject('Magento\Framework\Data\Form\Element\Collection');
         $this->_elementMock->expects($this->any())->method('getElements')->will($this->returnValue($collection));
+        $this->_elementMock->expects($this->any())->method('getIsNested')->will($this->returnValue($nested));
+        $this->_elementMock->expects($this->any())->method('getExpanded')->will($this->returnValue($expanded));
         $actualHtml = $this->_object->render($this->_elementMock);
-        $this->assertContains($this->_testData['htmlId'], $actualHtml);
-        $this->assertContains($this->_testData['legend'], $actualHtml);
-        $this->assertContains($this->_testData['comment'], $actualHtml);
+        $this->assertContains($this->testData['htmlId'], $actualHtml);
+        $this->assertContains($this->testData['legend'], $actualHtml);
+        $this->assertContains($this->testData['comment'], $actualHtml);
+        if ($nested) {
+            $this->assertContains('nested', $actualHtml);
+        }
     }
 
-    public function testRenderWithStoredElements()
+    /**
+     * @param $expanded
+     * @param $nested
+     * @param $extra
+     * @dataProvider testRenderWithStoredElementsDataProvider
+     */
+    public function testRenderWithStoredElements($expanded, $nested, $extra)
     {
+        $this->userMock->expects($this->any())->method('getExtra')->willReturn($extra);
         $this->_helperMock->expects($this->any())->method('getScript')->will($this->returnArgument(0));
-
-        $fieldMock = $this->getMock(
-            'Magento\Framework\Data\Form\Element\Text',
-            ['getId', 'getTooltip', 'toHtml'],
-            [],
-            '',
-            false,
-            false,
-            true
-        );
-
+        $fieldMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Text')
+            ->setMethods(['getId', 'getTooltip', 'toHtml', 'getHtmlId', 'getIsNested', 'getExpanded'])
+            ->disableOriginalConstructor()
+            ->getMock();
         $fieldMock->expects($this->any())->method('getId')->will($this->returnValue('test_field_id'));
         $fieldMock->expects($this->any())->method('getTooltip')->will($this->returnValue('test_field_tootip'));
         $fieldMock->expects($this->any())->method('toHtml')->will($this->returnValue('test_field_toHTML'));
+        $fieldMock->expects($this->any())->method('getHtmlId')->willReturn('test_field_HTML_id');
+
+        $fieldSetMock = $this->getMockBuilder('Magento\Framework\Data\Form\Element\Fieldset')
+            ->setMethods(['getId', 'getTooltip', 'toHtml', 'getHtmlId', 'getIsNested', 'getExpanded'])
+            ->disableOriginalConstructor()
+            ->getMock();
+        $fieldSetMock->expects($this->any())->method('getId')->will($this->returnValue('test_fieldset_id'));
+        $fieldSetMock->expects($this->any())->method('getTooltip')->will($this->returnValue('test_fieldset_tootip'));
+        $fieldSetMock->expects($this->any())->method('toHtml')->will($this->returnValue('test_fieldset_toHTML'));
+        $fieldSetMock->expects($this->any())->method('getHtmlId')->willReturn('test_fieldset_HTML_id');
 
-        $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
         $factory = $this->getMock('Magento\Framework\Data\Form\Element\Factory', [], [], '', false);
+
         $factoryColl = $this->getMock(
             'Magento\Framework\Data\Form\Element\CollectionFactory',
             [],
@@ -167,13 +201,19 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
             '',
             false
         );
+
         $formMock = $this->getMock('Magento\Framework\Data\Form\AbstractForm', [], [$factory, $factoryColl]);
-        $collection = $helper->getObject(
+
+        $collection = $this->_testHelper->getObject(
             'Magento\Framework\Data\Form\Element\Collection',
             ['container' => $formMock]
         );
         $collection->add($fieldMock);
+        $collection->add($fieldSetMock);
+
         $this->_elementMock->expects($this->any())->method('getElements')->will($this->returnValue($collection));
+        $this->_elementMock->expects($this->any())->method('getIsNested')->will($this->returnValue($nested));
+        $this->_elementMock->expects($this->any())->method('getExpanded')->will($this->returnValue($expanded));
 
         $actual = $this->_object->render($this->_elementMock);
 
@@ -182,5 +222,48 @@ class FieldsetTest extends \PHPUnit_Framework_TestCase
         $expected = '<div id="row_test_field_id_comment" class="system-tooltip-box"' .
             ' style="display:none;">test_field_tootip</div>';
         $this->assertContains($expected, $actual);
+        if ($nested) {
+            $this->assertContains('nested', $actual);
+        }
+    }
+
+    /**
+     * @return array
+     */
+    public function testRenderWithoutStoredElementsDataProvider()
+    {
+        return $this->dataProvider();
+    }
+
+    /**
+     * @return array
+     */
+    public function testRenderWithStoredElementsDataProvider()
+    {
+        return $this->dataProvider();
+    }
+
+    /**
+     * @return array
+     */
+    protected function dataProvider()
+    {
+        return [
+            'expandedNestedExtra' => [
+                'expanded' => true,
+                'nested'   => true,
+                'extra'    => [],
+            ],
+            'collapsedNotNestedExtra' => [
+                'expanded' => false,
+                'nested'   => false,
+                'extra'    => ['configState' => [$this->testData['htmlId'] => true]],
+            ],
+            'collapsedNotNestedNoExtra' => [
+                'expanded' => false,
+                'nested'   => false,
+                'extra'    => [],
+            ],
+        ];
     }
 }
diff --git a/app/code/Magento/Email/Model/Template.php b/app/code/Magento/Email/Model/Template.php
index a349f5d9ed0708300e369fb97800dc258f3ded2d..2bb54a0333a138ec34f36e4362d22018e2fbef1d 100644
--- a/app/code/Magento/Email/Model/Template.php
+++ b/app/code/Magento/Email/Model/Template.php
@@ -7,7 +7,6 @@ namespace Magento\Email\Model;
 
 use Magento\Email\Model\Template\Filter;
 use Magento\Framework\App\Filesystem\DirectoryList;
-use Magento\Framework\Filter\Template as FilterTemplate;
 use Magento\Store\Model\ScopeInterface;
 use Magento\Store\Model\StoreManagerInterface;
 
@@ -76,7 +75,7 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento
     /**
      * Email template filter
      *
-     * @var FilterTemplate
+     * @var Filter
      */
     protected $_templateFilter;
 
@@ -278,10 +277,10 @@ class Template extends \Magento\Email\Model\AbstractTemplate implements \Magento
     /**
      * Declare template processing filter
      *
-     * @param FilterTemplate $filter
+     * @param Filter $filter
      * @return $this
      */
-    public function setTemplateFilter(FilterTemplate $filter)
+    public function setTemplateFilter(Filter $filter)
     {
         $this->_templateFilter = $filter;
         return $this;
diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php
index c95b3f4e21572e16f38fdb967abf3ccc25a582e8..18ed7a756916ecbd28a78ef4fa82b562950c953a 100644
--- a/app/code/Magento/Email/Model/Template/Filter.php
+++ b/app/code/Magento/Email/Model/Template/Filter.php
@@ -110,6 +110,13 @@ class Filter extends \Magento\Framework\Filter\Template
      */
     protected $backendUrlBuilder;
 
+    /**
+     * Include processor
+     *
+     * @var callable|null
+     */
+    protected $_includeProcessor = null;
+
     /**
      * @param \Magento\Framework\Stdlib\String $string
      * @param \Psr\Log\LoggerInterface $logger
@@ -216,6 +223,49 @@ class Filter extends \Magento\Framework\Filter\Template
         return $this->_storeId;
     }
 
+    /**
+     * @param string[] $construction
+     * @return mixed
+     */
+    public function includeDirective($construction)
+    {
+        // Processing of {include template=... [...]} statement
+        $includeParameters = $this->_getIncludeParameters($construction[2]);
+        if (!isset($includeParameters['template']) or !$this->getIncludeProcessor()) {
+            // Not specified template or not set include processor
+            $replacedValue = '{Error in include processing}';
+        } else {
+            // Including of template
+            $templateCode = $includeParameters['template'];
+            unset($includeParameters['template']);
+            $includeParameters = array_merge_recursive($includeParameters, $this->_templateVars);
+            $replacedValue = call_user_func($this->getIncludeProcessor(), $templateCode, $includeParameters);
+        }
+        return $replacedValue;
+    }
+
+    /**
+     * Sets the processor of includes.
+     *
+     * @param callable $callback it must return string
+     * @return $this
+     */
+    public function setIncludeProcessor(array $callback)
+    {
+        $this->_includeProcessor = $callback;
+        return $this;
+    }
+
+    /**
+     * Sets the processor of includes.
+     *
+     * @return callable|null
+     */
+    public function getIncludeProcessor()
+    {
+        return is_callable($this->_includeProcessor) ? $this->_includeProcessor : null;
+    }
+
     /**
      * Retrieve Block html directive
      *
diff --git a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
index 3c89c3a8532971729ea0a7fcbb408ef0854fb2a3..eddac2ab9c0b1b67de2d660a25e910f713019bdf 100644
--- a/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
+++ b/app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
@@ -71,6 +71,11 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
      */
     private $emailConfig;
 
+    /**
+     * @var \Magento\Email\Model\Template\Filter|\PHPUnit_Framework_MockObject_MockObject
+     */
+    private $filterTemplate;
+
     public function setUp()
     {
         $this->context = $this->getMockBuilder('Magento\Framework\Model\Context')
@@ -107,6 +112,18 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
         $this->emailConfig = $this->getMockBuilder('Magento\Email\Model\Template\Config')
             ->disableOriginalConstructor()
             ->getMock();
+        $this->filterTemplate = $this->getMockBuilder('Magento\Email\Model\Template\Filter')
+            ->disableOriginalConstructor()
+            ->getMock();
+        $this->filterTemplate->expects($this->any())
+            ->method('setUseAbsoluteLinks')
+            ->will($this->returnSelf());
+        $this->filterTemplate->expects($this->any())
+            ->method('setStoreId')
+            ->will($this->returnSelf());
+        $this->emailFilterFactory->expects($this->any())
+            ->method('create')
+            ->will($this->returnValue($this->filterTemplate));
     }
 
     /**
@@ -150,27 +167,12 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
     public function testSetAndGetTemplateFilter()
     {
         $model = $this->getModelMock();
-        $filterTemplate = $this->getMockBuilder('Magento\Framework\Filter\Template')
-            ->disableOriginalConstructor()
-            ->getMock();
-        $model->setTemplateFilter($filterTemplate);
-        $this->assertSame($filterTemplate, $model->getTemplateFilter());
+        $model->setTemplateFilter($this->filterTemplate);
+        $this->assertSame($this->filterTemplate, $model->getTemplateFilter());
     }
 
     public function testGetTemplateFilterWithEmptyValue()
     {
-        $filterTemplate = $this->getMockBuilder('Magento\Framework\Filter\Template')
-            ->setMethods(['setUseAbsoluteLinks', 'setStoreId'])
-            ->disableOriginalConstructor()
-            ->getMock();
-        $filterTemplate->expects($this->once())
-            ->method('setUseAbsoluteLinks')
-            ->will($this->returnSelf());
-        $filterTemplate->expects($this->once())
-            ->method('setStoreId')
-            ->will($this->returnSelf());
-        $this->emailFilterFactory->method('create')
-            ->will($this->returnValue($filterTemplate));
         $designConfig = $this->getMockBuilder('Magento\Framework\Object')
             ->setMethods(['getStore'])
             ->disableOriginalConstructor()
@@ -181,7 +183,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
             ->method('getDesignConfig')
             ->will($this->returnValue($designConfig));
 
-        $this->assertSame($filterTemplate, $model->getTemplateFilter());
+        $this->assertSame($this->filterTemplate, $model->getTemplateFilter());
     }
 
     /**
@@ -408,29 +410,18 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
      */
     public function testGetProcessedTemplate($variables, $templateType, $storeId, $expectedVariables, $expectedResult)
     {
-        $filterTemplate = $this->getMockBuilder('Magento\Framework\Filter\Template')
-            ->setMethods([
-                'setUseSessionInUrl',
-                'setPlainTemplateMode',
-                'setVariables',
-                'setStoreId',
-                'filter',
-                'getStoreId',
-            ])
-            ->disableOriginalConstructor()
-            ->getMock();
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('setUseSessionInUrl')
             ->with(false)
             ->will($this->returnSelf());
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('setPlainTemplateMode')
             ->with($templateType === \Magento\Framework\App\TemplateTypesInterface::TYPE_TEXT)
             ->will($this->returnSelf());
-        $filterTemplate->expects($this->any())
+        $this->filterTemplate->expects($this->any())
             ->method('setStoreId')
             ->will($this->returnSelf());
-        $filterTemplate->expects($this->any())
+        $this->filterTemplate->expects($this->any())
             ->method('getStoreId')
             ->will($this->returnValue($storeId));
 
@@ -446,7 +437,6 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
             ->will($this->returnValue($store));
 
         $model = $this->getModelMock(['getDesignConfig', '_applyDesignConfig', 'getPreparedTemplateText']);
-        $model->setTemplateFilter($filterTemplate);
         $model->setTemplateType($templateType);
 
         $designConfig = $this->getMockBuilder('Magento\Framework\Object')
@@ -454,13 +444,19 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
         $storeId = 'storeId';
-        $designConfig->expects($this->once())
+        $designConfig->expects($this->exactly(2))
             ->method('getStore')
             ->will($this->returnValue($storeId));
         $model->expects($this->once())
+            ->method('_applyDesignConfig')
+            ->willReturnSelf();
+        $model->expects($this->exactly(2))
             ->method('getDesignConfig')
             ->will($this->returnValue($designConfig));
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
+            ->method('setIncludeProcessor')
+            ->willReturnSelf();
+        $this->filterTemplate->expects($this->once())
             ->method('setVariables')
             ->with(array_merge([ 'this' => $model], $expectedVariables));
 
@@ -468,7 +464,7 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
         $model->expects($this->once())
             ->method('getPreparedTemplateText')
             ->will($this->returnValue($preparedTemplateText));
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('filter')
             ->with($preparedTemplateText)
             ->will($this->returnValue($expectedResult));
@@ -556,13 +552,9 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
         $templateSubject = 'templateSubject';
         $model->setTemplateSubject($templateSubject);
 
-        $filterTemplate = $this->getMockBuilder('Magento\Framework\Filter\Template')
-            ->setMethods(['setVariables', 'setStoreId', 'filter'])
-            ->disableOriginalConstructor()
-            ->getMock();
         $model->expects($this->once())
             ->method('getTemplateFilter')
-            ->will($this->returnValue($filterTemplate));
+            ->will($this->returnValue($this->filterTemplate));
 
         $model->expects($this->once())
             ->method('_applyDesignConfig');
@@ -579,18 +571,18 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
             ->method('getDesignConfig')
             ->will($this->returnValue($designConfig));
 
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('setStoreId')
             ->with($storeId)
             ->will($this->returnSelf());
         $expectedResult = 'expected';
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('filter')
             ->with($templateSubject)
             ->will($this->returnValue($expectedResult));
 
         $variables = [ 'key' => 'value' ];
-        $filterTemplate->expects($this->once())
+        $this->filterTemplate->expects($this->once())
             ->method('setVariables')
             ->with(array_merge($variables, ['this' => $model]));
         $this->assertEquals($expectedResult, $model->getProcessedTemplateSubject($variables));
diff --git a/lib/internal/Magento/Framework/Filter/Template.php b/lib/internal/Magento/Framework/Filter/Template.php
index 50db67715c20e9c3dd1adaea1bbb8e98a181cb4e..5c6fede1d57b6cf4f5a0faeaebec9360322bbf1d 100644
--- a/lib/internal/Magento/Framework/Filter/Template.php
+++ b/lib/internal/Magento/Framework/Filter/Template.php
@@ -32,13 +32,6 @@ class Template implements \Zend_Filter_Interface
      */
     protected $_templateVars = [];
 
-    /**
-     * Include processor
-     *
-     * @var callable|null
-     */
-    protected $_includeProcessor = null;
-
     /**
      * @var \Magento\Framework\Stdlib\String
      */
@@ -68,28 +61,6 @@ class Template implements \Zend_Filter_Interface
         return $this;
     }
 
-    /**
-     * Sets the processor of includes.
-     *
-     * @param callable $callback it must return string
-     * @return $this
-     */
-    public function setIncludeProcessor(array $callback)
-    {
-        $this->_includeProcessor = $callback;
-        return $this;
-    }
-
-    /**
-     * Sets the processor of includes.
-     *
-     * @return callable|null
-     */
-    public function getIncludeProcessor()
-    {
-        return is_callable($this->_includeProcessor) ? $this->_includeProcessor : null;
-    }
-
     /**
      * Filter the string as template.
      *
@@ -153,27 +124,6 @@ class Template implements \Zend_Filter_Interface
         return $replacedValue;
     }
 
-    /**
-     * @param string[] $construction
-     * @return mixed
-     */
-    public function includeDirective($construction)
-    {
-        // Processing of {include template=... [...]} statement
-        $includeParameters = $this->_getIncludeParameters($construction[2]);
-        if (!isset($includeParameters['template']) or !$this->getIncludeProcessor()) {
-            // Not specified template or not set include processor
-            $replacedValue = '{Error in include processing}';
-        } else {
-            // Including of template
-            $templateCode = $includeParameters['template'];
-            unset($includeParameters['template']);
-            $includeParameters = array_merge_recursive($includeParameters, $this->_templateVars);
-            $replacedValue = call_user_func($this->getIncludeProcessor(), $templateCode, $includeParameters);
-        }
-        return $replacedValue;
-    }
-
     /**
      * @param string[] $construction
      * @return string