diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
index f417b18..83f2033 100644
--- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
+++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php
@@ -702,7 +702,7 @@ public function findTables($table_expression) {
 
     // Can't use query placeholders for the schema because the query would have
     // to be :prefixsqlite_master, which does not work.
-    $result = db_query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE type = :type AND name LIKE :table_name", array(
+    $result = $this->connection->query("SELECT name FROM " . $info['schema'] . ".sqlite_master WHERE type = :type AND name LIKE :table_name", array(
       ':type' => 'table',
       ':table_name' => $info['table'],
     ));
diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php
index b9ff670..c91b5ff 100644
--- a/core/lib/Drupal/Core/Database/Schema.php
+++ b/core/lib/Drupal/Core/Database/Schema.php
@@ -16,6 +16,9 @@
  */
 abstract class Schema implements PlaceholderInterface {
 
+  /**
+   * @var \Drupal\Core\Database\Connection
+   */
   protected $connection;
 
   /**
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 3e76905..f6a6491 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -591,6 +591,20 @@ protected function tearDown() {
       $this->kernel->shutdown();
     }
 
+    // Remove all prefixed tables.
+    $original_connection_info = Database::getConnectionInfo('simpletest_original_default');
+    $original_prefix = $original_connection_info['default']['prefix']['default'];
+    $test_connection_info = Database::getConnectionInfo('default');
+    $test_prefix = $test_connection_info['default']['prefix']['default'];
+    if ($original_prefix != $test_prefix) {
+      $tables = Database::getConnection()->schema()->findTables('%');
+      foreach ($tables as $table) {
+        if (Database::getConnection()->schema()->dropTable($table)) {
+          unset($tables[$table]);
+        }
+      }
+    }
+
     // Free up memory: Own properties.
     $this->classLoader = NULL;
     $this->vfsRoot = NULL;
@@ -618,13 +632,20 @@ protected function tearDown() {
     $this->container = NULL;
     new Settings(array());
 
+    parent::tearDown();
+  }
+
+  /**
+   * @after
+   *
+   * Additional tear down method to close the connection at the end.
+   */
+  public function tearDownCloseDatabaseConnection() {
     // Destroy the database connection, which for example removes the memory
     // from sqlite in memory.
     foreach (Database::getAllConnectionInfo() as $key => $targets) {
       Database::removeConnection($key);
     }
-
-    parent::tearDown();
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index 2deaa95..11ced18 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\KernelTests;
 
+use Drupal\Core\Database\Database;
 use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\visitor\vfsStreamStructureVisitor;
 
@@ -19,7 +20,7 @@ class KernelTestBaseTest extends KernelTestBase {
   /**
    * @covers ::setUpBeforeClass
    */
-  public function testSetUpBeforeClass() {
+  public function ptestSetUpBeforeClass() {
     // Note: PHPUnit automatically restores the original working directory.
     $this->assertSame(realpath(__DIR__ . '/../../../../'), getcwd());
   }
@@ -27,7 +28,7 @@ public function testSetUpBeforeClass() {
   /**
    * @covers ::bootEnvironment
    */
-  public function testBootEnvironment() {
+  public function ptestBootEnvironment() {
     $this->assertRegExp('/^simpletest\d{6}$/', $this->databasePrefix);
     $this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory);
     $this->assertEquals(array(
@@ -51,31 +52,15 @@ public function testBootEnvironment() {
   /**
    * @covers ::getDatabaseConnectionInfo
    */
-  public function testGetDatabaseConnectionInfoWithOutManualSetDbUrl() {
-    $this->setUp();
-
+  public function ptestGetDatabaseConnectionInfoWithOutManualSetDbUrl() {
     $options = $this->container->get('database')->getConnectionOptions();
     $this->assertSame($this->databasePrefix, $options['prefix']['default']);
   }
 
   /**
-   * @covers ::getDatabaseConnectionInfo
-   */
-  public function testGetDatabaseConnectionInfoWithManualSetDbUrl() {
-    if (!file_exists('/tmp')) {
-      $this->markTestSkipped();
-    }
-    putenv('SIMPLETEST_DB=sqlite://localhost//tmp/test2.sqlite');
-    $this->setUp();
-
-    $options = $this->container->get('database')->getConnectionOptions();
-    $this->assertNotEqual('', $options['prefix']['default']);
-  }
-
-  /**
    * @covers ::setUp
    */
-  public function testSetUp() {
+  public function ptestSetUp() {
     $this->assertTrue($this->container->has('request_stack'));
     $this->assertTrue($this->container->initialized('request_stack'));
     $request = $this->container->get('request_stack')->getCurrentRequest();
@@ -106,7 +91,7 @@ public function testSetUp() {
    * @covers ::setUp
    * @depends testSetUp
    */
-  public function testSetUpDoesNotLeak() {
+  public function ptestSetUpDoesNotLeak() {
     $this->assertArrayNotHasKey('destroy-me', $GLOBALS);
 
     // Ensure that we have a different database prefix.
@@ -117,7 +102,7 @@ public function testSetUpDoesNotLeak() {
   /**
    * @covers ::register
    */
-  public function testRegister() {
+  public function ptestRegister() {
     // Verify that this container is identical to the actual container.
     $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $this->container);
     $this->assertSame($this->container, \Drupal::getContainer());
@@ -152,7 +137,7 @@ public function testRegister() {
    *
    * The point of this test is to have integration level testing.
    */
-  public function testCompiledContainer() {
+  public function ptestCompiledContainer() {
     $this->enableModules(['system', 'user']);
     $this->assertNull($this->installConfig('user'));
   }
@@ -163,7 +148,7 @@ public function testCompiledContainer() {
    *
    * The point of this test is to have integration level testing.
    */
-  public function testCompiledContainerIsDestructed() {
+  public function ptestCompiledContainerIsDestructed() {
     $this->enableModules(['system', 'user']);
     $this->assertNull($this->installConfig('user'));
   }
@@ -171,7 +156,7 @@ public function testCompiledContainerIsDestructed() {
   /**
    * @covers ::render
    */
-  public function testRender() {
+  public function ptestRender() {
     $type = 'processed_text';
     $element_info = $this->container->get('element_info');
     $this->assertSame(['#defaults_loaded' => TRUE], $element_info->getInfo($type));
@@ -216,4 +201,29 @@ public function testRenderWithTheme() {
     $this->assertRegExp($expected, (string) $output);
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  protected function tearDown() {
+    parent::tearDown();
+
+    // Check that all tables of the test instance have been deleted. At this
+    // point the original database connection is restored so we need to prefix
+    // the tables.
+    $connection = Database::getConnection();
+    if ($connection->databaseType() != 'sqlite') {
+      $tables = $connection->schema()->findTables($this->databasePrefix . '%');
+      $this->assertTrue(empty($tables), 'All test tables have been removed.');
+    }
+    else {
+      $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array(
+        ':type' => 'table',
+        ':table_name' => '%',
+        ':pattern' => 'sqlite_%',
+      ))->fetchAllKeyed(0, 0);
+
+     $this->assertTrue(empty($result), 'All test tables have been removed.');
+    }
+  }
+
 }
