diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 81264d1..4ca2a2a 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1459,16 +1459,13 @@ class DrupalWebTestCase extends DrupalTestCase {
     // Delete temporary files directory.
     file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
 
-    // Remove all prefixed tables (all the tables in the schema).
-    $schema = drupal_get_schema(NULL, TRUE);
-    foreach ($schema as $name => $table) {
-      db_drop_table($name);
-    }
-
     // Get back to the original connection.
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
 
+    // Remove all tables with the given prefix.
+    simpletest_clean_database_by_prefix($this->databasePrefix);
+
     // Restore original shutdown callbacks array to prevent original
     // environment of calling handlers from test run.
     $callbacks = &drupal_register_shutdown_function();
diff --git a/modules/simpletest/simpletest.module b/modules/simpletest/simpletest.module
index 310dc35..20a8556 100644
--- a/modules/simpletest/simpletest.module
+++ b/modules/simpletest/simpletest.module
@@ -434,8 +434,8 @@ function simpletest_clean_database() {
   foreach (array_diff_key($tables, $schema) as $table) {
     // Strip the prefix and skip tables without digits following "simpletest",
     // e.g. {simpletest_test_id}.
-    if (preg_match('/simpletest\d+.*/', $table, $matches)) {
-      db_drop_table($matches[0]);
+    if (simpletest_valid_prefix($table)) {
+      db_drop_table($table);
       $count++;
     }
   }
@@ -449,6 +449,35 @@ function simpletest_clean_database() {
 }
 
 /**
+ * Remove prefixed tables for a certain database prefix.
+ *
+ * @param $prefix
+ *   The specific prefix to clean.
+ */
+function simpletest_clean_database_by_prefix($prefix) {
+  // Only proceed if the database prefix is valid.
+  if (!simpletest_valid_prefix($prefix)) {
+    return;
+  }
+
+  // Find and drop all tables with the given prefix.
+  array_map('db_drop_table', db_find_tables($prefix . '%'));
+}
+
+/**
+ * Determine whether a given database prefix is a valid simpletest prefix.
+ *
+ * @param $prefix
+ *   The database prefix.
+ *
+ * @return
+ *   TRUE if the table is a valid simpletest table, and FALSE otherwise.
+ */
+function simpletest_valid_prefix($prefix) {
+  return preg_match('/simpletest\d+.*/', $prefix);
+}
+
+/**
  * Find all leftover temporary directories and remove them.
  */
 function simpletest_clean_temporary_directories() {
diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index e5b6042..cfe7b0c 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -151,6 +151,13 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
       // Regression test for #290316.
       // Check that test_id is incrementing.
       $this->assertTrue($this->test_ids[0] != $this->test_ids[1], t('Test ID is incrementing.'));
+
+      // Confirm that the only simpletest tables are those from the test run.
+      $all_simpletest_tables = db_find_tables('simpletest%');
+      unset($all_simpletest_tables['simpletest']);
+      unset($all_simpletest_tables['simpletest_test_id']);
+      $this_simpletest_tables = db_find_tables($this->databasePrefix . '%');
+      $this->assertIdentical($all_simpletest_tables, $this_simpletest_tables);
     }
   }
 
@@ -176,6 +183,11 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
     array_key_exists(NULL, NULL);
 
     debug('Foo', 'Debug');
+
+    // Enable and disable a module to ensure that clean up of database tables
+    // runs correctly.
+    module_enable(array('comment'));
+    module_disable(array('comment'));
   }
 
   /**
