diff --git a/tests/src/Kernel/ServerChangesTest.php b/tests/src/Kernel/ServerChangesTest.php
new file mode 100644
index 0000000..8378874
--- /dev/null
+++ b/tests/src/Kernel/ServerChangesTest.php
@@ -0,0 +1,142 @@
+<?php
+
+namespace Drupal\Tests\search_api\Kernel;
+
+use Drupal\KernelTests\KernelTestBase;
+use Drupal\search_api\Entity\Index;
+use Drupal\search_api\Entity\Server;
+use Drupal\search_api_test\PluginTestTrait;
+
+/**
+ * Tests whether changes for the server are processed correctly.
+ *
+ * @group search_api
+ */
+class ServerChangesTest extends KernelTestBase {
+
+  use PluginTestTrait;
+
+  /**
+   * The test server.
+   *
+   * @var \Drupal\search_api\ServerInterface
+   */
+  protected $server;
+
+  /**
+   * The test index.
+   *
+   * @var \Drupal\search_api\IndexInterface
+   */
+  protected $index;
+
+  /**
+   * The content entity datasource.
+   *
+   * @var \Drupal\search_api\Datasource\DatasourceInterface
+   */
+  protected $datasource;
+
+  /**
+   * Modules to enable for this test.
+   *
+   * @var string[]
+   */
+  public static $modules = array(
+    'search_api',
+    'search_api_test',
+    'user',
+    'system',
+  );
+
+  /**
+   * The task manager to use for the tests.
+   *
+   * @var \Drupal\search_api\Task\TaskManagerInterface
+   */
+  protected $taskManager;
+
+  /**
+   * The server task manager to use for the tests.
+   *
+   * @var \Drupal\search_api\Task\ServerTaskManagerInterface
+   */
+  protected $serverTaskManager;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setUp() {
+    parent::setUp();
+
+    $this->installEntitySchema('user');
+    $this->installSchema('search_api', array('search_api_item', 'search_api_task'));
+    $this->installSchema('system', array('key_value_expire'));
+
+    // Set tracking page size so tracking will work properly.
+    \Drupal::configFactory()
+      ->getEditable('search_api.settings')
+      ->set('tracking_page_size', 100)
+      ->save();
+
+    // Create a test server.
+    $this->server = Server::create(array(
+      'name' => 'Test Server',
+      'id' => 'test_server',
+      'status' => 1,
+      'backend' => 'search_api_test',
+    ));
+    $this->server->save();
+
+    // Create a test index.
+    $this->index = Index::create(array(
+      'name' => 'Test index',
+      'id' => 'test_index',
+      'status' => 1,
+      'datasource_settings' => array(
+        'entity:user' => array(
+          'plugin_id' => 'entity:user',
+          'settings' => array(),
+        ),
+      ),
+      'tracker_settings' => array(
+        'default' => array(
+          'plugin_id' => 'default',
+          'settings' => array(),
+        ),
+      ),
+      'server' => $this->server->id(),
+      'options' => array('index_directly' => FALSE),
+    ));
+
+    // Reset the list of called backend methods.
+    $this->getCalledMethods('backend');
+  }
+
+  /**
+   * Tests adding and removing of indexes.
+   */
+  public function testAddRemoveIndex() {
+    $this->index->save();
+    $this->index->setServer(NULL)->save();
+    $this->index->setServer($this->server)->enable()->save();
+    $this->server->disable()->save();
+    $this->index->setServer(NULL)->save();
+    $this->server->enable()->save();
+    $this->index->setServer($this->server)->enable()->save();
+    $this->index->delete();
+
+    $methods = $this->getCalledMethods('backend');
+    $methods = array_intersect($methods, array('addIndex', 'removeIndex'));
+    $expected = array(
+      'addIndex',
+      'removeIndex',
+      'addIndex',
+      'removeIndex',
+      'addIndex',
+      'removeIndex',
+    );
+    $this->assertEquals($expected, array_values($methods));
+  }
+
+}
diff --git a/tests/src/Kernel/ServerStorageTest.php b/tests/src/Kernel/ServerStorageTest.php
index fac7011..2ccc0af 100644
--- a/tests/src/Kernel/ServerStorageTest.php
+++ b/tests/src/Kernel/ServerStorageTest.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Config\Entity\ConfigEntityStorage;
 use Drupal\search_api\ServerInterface;
 use Drupal\KernelTests\KernelTestBase;
+use Drupal\search_api_test\PluginTestTrait;
 
 /**
  * Tests whether the storage of search servers works correctly.
@@ -13,6 +14,8 @@
  */
 class ServerStorageTest extends KernelTestBase {
 
+  use PluginTestTrait;
+
   /**
    * Modules to enable for this test.
    *
@@ -52,6 +55,7 @@ public function testServerCrud() {
 
     $server = $this->serverCreate();
     $this->serverLoad($server);
+    $this->serverUpdate($server);
     $this->serverDelete($server);
   }
 
@@ -105,8 +109,7 @@ public function serverUpdate(ServerInterface $server) {
     $server->set('name', $server->label() . ' - edited');
     $server->save();
 
-    $key = 'search_api_test.methods_called.' . $server->id();
-    $methods_called = \Drupal::state()->get($key, array());
+    $methods_called = $this->getCalledMethods('backend');
     $this->assertContains('preUpdate', $methods_called, 'Backend::preUpdate() called for update.');
     $this->assertContains('postUpdate', $methods_called, 'Backend::postUpdate() called for update.');
 
