diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
index 950e2253a95dc21218ee666bb5d747b3991d3118..d2a3196868543db0fb9832aca40529df2c32f965 100644
--- a/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
+++ b/app/code/Magento/Catalog/Model/Product/Gallery/GalleryManagement.php
@@ -94,13 +94,16 @@ class GalleryManagement implements \Magento\Catalog\Api\ProductAttributeMediaGal
         }
         $found = false;
         foreach ($existingMediaGalleryEntries as $key => $existingEntry) {
+            $entryTypes = (array)$entry->getTypes();
+            $existingEntryTypes = (array)$existingMediaGalleryEntries[$key]->getTypes();
+            $existingMediaGalleryEntries[$key]->setTypes(array_diff($existingEntryTypes, $entryTypes));
+
             if ($existingEntry->getId() == $entry->getId()) {
                 $found = true;
                 if ($entry->getFile()) {
                     $entry->setId(null);
                 }
                 $existingMediaGalleryEntries[$key] = $entry;
-                break;
             }
         }
         if (!$found) {
diff --git a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
index 3c757f8a05a2daf0ab30c9efb2031c15cefa1d4f..ec2521350d14d991e9c8deff2a74f5ff4865fbfc 100644
--- a/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
+++ b/app/code/Magento/Catalog/Model/Product/Gallery/Processor.php
@@ -298,11 +298,11 @@ class Processor
         if (is_array($mediaAttribute)) {
             foreach ($mediaAttribute as $attribute) {
                 if (in_array($attribute, $mediaAttributeCodes)) {
-                    $product->setData($attribute, null);
+                    $product->setData($attribute, 'no_selection');
                 }
             }
         } elseif (in_array($mediaAttribute, $mediaAttributeCodes)) {
-            $product->setData($mediaAttribute, null);
+            $product->setData($mediaAttribute, 'no_selection');
         }
 
         return $this;
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
index fb2d197749e01bdd15b1574d2fca4831a04e4583..e3845a2b51cec716d37e27430023ee2be2409bef 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/GalleryManagementTest.php
@@ -191,20 +191,33 @@ class GalleryManagementTest extends \PHPUnit_Framework_TestCase
         $productSku = 'testProduct';
         $entryMock = $this->getMock(\Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class);
         $entryId = 42;
+        $entrySecondId = 43;
         $this->productRepositoryMock->expects($this->once())->method('get')->with($productSku)
             ->willReturn($this->productMock);
         $existingEntryMock = $this->getMock(
             \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
         );
+        $existingSecondEntryMock = $this->getMock(
+            \Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface::class
+        );
+
         $existingEntryMock->expects($this->once())->method('getId')->willReturn($entryId);
+        $existingEntryMock->expects($this->once())->method('getTypes')->willReturn(['small_image']);
+        $existingEntryMock->expects($this->once())->method('setTypes')->with(['small_image']);
+        $existingSecondEntryMock->expects($this->once())->method('getId')->willReturn($entrySecondId);
+        $existingSecondEntryMock->expects($this->once())->method('getTypes')->willReturn(['image']);
+        $existingSecondEntryMock->expects($this->once())->method('setTypes')->with([]);
         $this->productMock->expects($this->once())->method('getMediaGalleryEntries')
-            ->willReturn([$existingEntryMock]);
-        $entryMock->expects($this->once())->method('getId')->willReturn($entryId);
+            ->willReturn([$existingEntryMock, $existingSecondEntryMock]);
+
+        $entryMock->expects($this->exactly(2))->method('getId')->willReturn($entryId);
         $entryMock->expects($this->once())->method('getFile')->willReturn("base64");
         $entryMock->expects($this->once())->method('setId')->with(null);
+        $entryMock->expects($this->exactly(2))->method('getTypes')->willReturn(['image']);
 
         $this->productMock->expects($this->once())->method('setMediaGalleryEntries')
-            ->willReturn([$entryMock]);
+            ->with([$entryMock, $existingSecondEntryMock])
+            ->willReturnSelf();
         $this->productRepositoryMock->expects($this->once())->method('save')->with($this->productMock);
         $this->assertTrue($this->model->update($productSku, $entryMock));
     }
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
index 61d4e3a5c76d5a3fdf57438c082a210c9b60ac5a..50c3c4ad0122c5490fa535c07fa7d677514d91c9 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Gallery/ProcessorTest.php
@@ -197,4 +197,56 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
             [false]
         ];
     }
+
+    /**
+     * @param int $setDataExpectsCalls
+     * @param string|null $setDataArgument
+     * @param array|string $mediaAttribute
+     * @dataProvider clearMediaAttributeDataProvider
+     */
+    public function testClearMediaAttribute($setDataExpectsCalls, $setDataArgument, $mediaAttribute)
+    {
+        $productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $productMock->expects($this->exactly($setDataExpectsCalls))
+            ->method('setData')
+            ->with($setDataArgument, 'no_selection');
+
+        $this->mediaConfig->expects($this->once())
+            ->method('getMediaAttributeCodes')
+            ->willReturn(['image', 'small_image']);
+
+        $this->assertSame($this->model, $this->model->clearMediaAttribute($productMock, $mediaAttribute));
+    }
+
+    /**
+     * @return array
+     */
+    public function clearMediaAttributeDataProvider()
+    {
+        return [
+            [
+                'setDataExpectsCalls' => 1,
+                'setDataArgument' => 'image',
+                'mediaAttribute' => 'image',
+            ],
+            [
+                'setDataExpectsCalls' => 1,
+                'setDataArgument' => 'image',
+                'mediaAttribute' => ['image'],
+            ],
+            [
+                'setDataExpectsCalls' => 0,
+                'setDataArgument' => null,
+                'mediaAttribute' => 'some_image',
+            ],
+            [
+                'setDataExpectsCalls' => 0,
+                'setDataArgument' => null,
+                'mediaAttribute' => ['some_image'],
+            ],
+        ];
+    }
 }
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php
index 324404ead6c9f5845526512ed6ed39e87f94157c..0f5a0a425a5a5358cf98715827a7950d5e0489fd 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeMediaGalleryManagementInterfaceTest.php
@@ -237,8 +237,8 @@ class ProductAttributeMediaGalleryManagementInterfaceTest extends \Magento\TestF
 
         $targetProduct = $this->getTargetSimpleProduct();
         $this->assertEquals('/m/a/magento_image.jpg', $targetProduct->getData('thumbnail'));
-        $this->assertNull($targetProduct->getData('image'));
-        $this->assertNull($targetProduct->getData('small_image'));
+        $this->assertEquals('no_selection', $targetProduct->getData('image'));
+        $this->assertEquals('no_selection', $targetProduct->getData('small_image'));
         $mediaGallery = $targetProduct->getData('media_gallery');
         $this->assertCount(1, $mediaGallery['images']);
         $updatedImage = array_shift($mediaGallery['images']);
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php
index de6adb0efd8b21df23cf0531624fa0b90983225d..5baf4a4cb7c3e273588d85c1217e6824cdefad92 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View.php
@@ -522,14 +522,16 @@ class View extends AbstractConfigureBlock
     }
 
     /**
-     * Check id media gallery is visible for the product.
+     * Check if media gallery is visible for the product.
      *
      * @return bool
      */
     public function isGalleryVisible()
     {
         $this->waitForElementNotVisible($this->galleryLoader);
-        return $this->_rootElement->find($this->mediaGallery)->isVisible();
+        $this->waitForElementVisible($this->mediaGallery);
+
+        return true;
     }
 
     /**
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ProcessorTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ProcessorTest.php
index 9c9e564939070e99b097477a221f445811a25ef1..ae954fdc7cfbb7bdc7c66dfb4ab9a25e977e8fae 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ProcessorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ProcessorTest.php
@@ -146,15 +146,15 @@ class ProcessorTest extends \PHPUnit_Framework_TestCase
         );
         $product->setData(['image' => 'test1', 'small_image' => 'test2', 'thumbnail' => 'test3']);
 
-        $this->assertNotEmpty($product->getData('image'));
+        $this->assertNotEquals('no_selection', $product->getData('image'));
         $this->_model->clearMediaAttribute($product, 'image');
-        $this->assertNull($product->getData('image'));
+        $this->assertEquals('no_selection', $product->getData('image'));
 
-        $this->assertNotEmpty($product->getData('small_image'));
-        $this->assertNotEmpty($product->getData('thumbnail'));
+        $this->assertNotEquals('no_selection', $product->getData('small_image'));
+        $this->assertNotEquals('no_selection', $product->getData('thumbnail'));
         $this->_model->clearMediaAttribute($product, ['small_image', 'thumbnail']);
-        $this->assertNull($product->getData('small_image'));
-        $this->assertNull($product->getData('thumbnail'));
+        $this->assertEquals('no_selection', $product->getData('small_image'));
+        $this->assertEquals('no_selection', $product->getData('thumbnail'));
     }
 
     public function testSetMediaAttribute()
diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php
index 389fd4b253eb7c8e8a89237f1b7a20be9aa777fe..95fd6110bb432e72daa2af66d7b65f7abbdb3d0f 100644
--- a/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php
@@ -62,12 +62,12 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
     {
         //skipping test if service is unavailable
         $url = str_replace('{{CURRENCY_FROM}}', 'USD',
-            \Magento\Directory\Model\Currency\Import\Webservicex::CURRENCY_CONVERTER_URL
+            \Magento\Directory\Model\Currency\Import\Webservicex::CURRENCY_CONVERTER_URL
         );
         $url = str_replace('{{CURRENCY_TO}}', 'GBP', $url);
         try {
             file_get_contents($url);
-        } catch (\PHPUnit_Framework_Error_Warning $e) {
+        } catch (\PHPUnit_Framework_Exception $e) {
             $this->markTestSkipped('http://www.webservicex.net is unavailable ');
         }