diff --git a/core/modules/config/lib/Drupal/config/ConfigStorageController.php b/core/modules/config/lib/Drupal/config/ConfigStorageController.php
index 4c4884c..7d760d2 100644
--- a/core/modules/config/lib/Drupal/config/ConfigStorageController.php
+++ b/core/modules/config/lib/Drupal/config/ConfigStorageController.php
@@ -283,18 +283,18 @@ class ConfigStorageController implements EntityStorageControllerInterface {
       $config->set($name, $entity->$name);
     }
 
-    if (!$config->isNew()) {
+    if ($config->isNew()) {
       $return = SAVED_NEW;
       $config->save();
-      $this->postSave($entity, TRUE);
-      $this->invokeHook('update', $entity);
+      $entity->enforceIsNew(FALSE);
+      $this->postSave($entity, FALSE);
+      $this->invokeHook('insert', $entity);
     }
     else {
       $return = SAVED_UPDATED;
       $config->save();
-      $entity->enforceIsNew(FALSE);
-      $this->postSave($entity, FALSE);
-      $this->invokeHook('insert', $entity);
+      $this->postSave($entity, TRUE);
+      $this->invokeHook('update', $entity);
     }
 
     unset($entity->original);
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
index 54b8641..532979c 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
@@ -45,7 +45,8 @@ class ConfigEntityTest extends WebTestBase {
     );
     $this->drupalPost('admin/structure/config_test/add', $edit, 'Save');
     $this->assertResponse(200);
-    $this->assertText($label1);
+    $message_insert = format_string('%label configuration has been created.', array('%label' => $label1));
+    $this->assertRaw($message_insert);
 
     // Update the configuration entity.
     $this->assertLinkByHref('admin/structure/config_test/manage/' . $id);
@@ -54,8 +55,9 @@ class ConfigEntityTest extends WebTestBase {
     );
     $this->drupalPost('admin/structure/config_test/manage/' . $id, $edit, 'Save');
     $this->assertResponse(200);
-    $this->assertNoText($label1);
-    $this->assertText($label2);
+    $message_update = format_string('%label configuration has been updated.', array('%label' => $label2));
+    $this->assertNoRaw($message_insert);
+    $this->assertRaw($message_update);
 
     // Delete the configuration entity.
     $this->assertLinkByHref('admin/structure/config_test/manage/' . $id . '/delete');
