diff --git a/core/modules/search/search.test b/core/modules/search/search.test
index 6085465..efec260 100644
--- a/core/modules/search/search.test
+++ b/core/modules/search/search.test
@@ -1589,7 +1589,7 @@ class SearchConfigSettingsForm extends SearchWebTestCase {
 /**
  * Tests the search_excerpt() function.
  */
-class SearchExcerptTestCase extends DrupalUnitTestCase {
+class SearchExcerptTestCase extends DrupalWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Search excerpt extraction',
@@ -1599,8 +1599,7 @@ class SearchExcerptTestCase extends DrupalUnitTestCase {
   }
 
   function setUp() {
-    drupal_load('module', 'search');
-    parent::setUp();
+    parent::setUp(array('search'));
   }
 
   /**
diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php
index 8b85dfc..6240672 100644
--- a/core/modules/simpletest/drupal_web_test_case.php
+++ b/core/modules/simpletest/drupal_web_test_case.php
@@ -542,6 +542,183 @@ abstract class DrupalTestCase {
   }
 
   /**
+   * Generates a database prefix for running tests.
+   *
+   * The generated database table prefix is used for the Drupal installation
+   * being performed for the test. It is also used as user agent HTTP header
+   * value by the cURL-based browser of DrupalWebTestCase, which is sent to the
+   * Drupal installation of the test. During early Drupal bootstrap, the user
+   * agent HTTP header is parsed, and if it matches, all database queries use
+   * the database table prefix that has been generated here.
+   *
+   * @see DrupalWebTestCase::curlInitialize()
+   * @see drupal_valid_test_ua()
+   * @see DrupalWebTestCase::setUp()
+   */
+  protected function prepareDatabasePrefix() {
+    $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
+
+    // As soon as the database prefix is set, the test might start to execute.
+    // All assertions as well as the SimpleTest batch operations are associated
+    // with the testId, so the database prefix has to be associated with it.
+    db_update('simpletest_test_id')
+      ->fields(array('last_prefix' => $this->databasePrefix))
+      ->condition('test_id', $this->testId)
+      ->execute();
+  }
+
+  /**
+   * Changes the database connection to the prefixed one.
+   *
+   * @see DrupalWebTestCase::setUp()
+   */
+  protected function changeDatabasePrefix() {
+    if (empty($this->databasePrefix)) {
+      $this->prepareDatabasePrefix();
+    }
+
+    // Clone the current connection and replace the current prefix.
+    $connection_info = Database::getConnectionInfo('default');
+    Database::renameConnection('default', 'simpletest_original_default');
+    foreach ($connection_info as $target => $value) {
+      $connection_info[$target]['prefix'] = array(
+        'default' => $value['prefix']['default'] . $this->databasePrefix,
+      );
+    }
+    Database::addConnectionInfo('default', 'default', $connection_info['default']);
+  }
+
+  /**
+   * Prepares the current environment for running the test.
+   *
+   * Backups various current environment variables and resets them, so they do
+   * not interfere with the Drupal site installation in which tests are executed
+   * and can be restored in tearDown().
+   *
+   * Also sets up new resources for the testing environment, such as the public
+   * filesystem and configuration directories.
+   *
+   * @see DrupalWebTestCase::setUp()
+   * @see DrupalWebTestCase::tearDown()
+   */
+  protected function prepareEnvironment() {
+    global $user, $language_interface, $conf;
+
+    // Store necessary current values before switching to prefixed database.
+    $this->originalContainer = clone drupal_container();
+    $this->originalLanguage = $language_interface;
+    $this->originalLanguageDefault = variable_get('language_default');
+    $this->originalConfigDirectory = $GLOBALS['config_directory_name'];
+    $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
+    $this->originalProfile = drupal_get_profile();
+    $this->originalUser = $user;
+
+    // Save and clean the shutdown callbacks array because it is static cached
+    // and will be changed by the test run. Otherwise it will contain callbacks
+    // from both environments and the testing environment will try to call the
+    // handlers defined by the original one.
+    $callbacks = &drupal_register_shutdown_function();
+    $this->originalShutdownCallbacks = $callbacks;
+    $callbacks = array();
+
+    // Create test directory ahead of installation so fatal errors and debug
+    // information can be logged during installation process.
+    // Use temporary files directory with the same prefix as the database.
+    $this->public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
+    $this->private_files_directory = $this->public_files_directory . '/private';
+    $this->temp_files_directory = $this->private_files_directory . '/temp';
+
+    // Create the directories
+    file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+    file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY);
+    file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY);
+    $this->generatedTestFiles = FALSE;
+
+    // Create and set a new configuration directory and signature key.
+    // The child site automatically adjusts the global $config_directory_name to
+    // a test-prefix-specific directory within the public files directory.
+    // @see config_get_config_directory()
+    $GLOBALS['config_directory_name'] = 'simpletest/' . substr($this->databasePrefix, 10) . '/config';
+    $this->configFileDirectory = $this->originalFileDirectory . '/' . $GLOBALS['config_directory_name'];
+    file_prepare_directory($this->configFileDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
+
+    // Log fatal errors.
+    ini_set('log_errors', 1);
+    ini_set('error_log', $this->public_files_directory . '/error.log');
+
+    // Set the test information for use in other parts of Drupal.
+    $test_info = &$GLOBALS['drupal_test_info'];
+    $test_info['test_run_id'] = $this->databasePrefix;
+    $test_info['in_child_site'] = FALSE;
+  }
+
+  /**
+   * Deletes created files, database tables, and reverts all environment changes.
+   *
+   * This method needs to be invoked for both unit and integration tests.
+   *
+   * @see DrupalTestCase::prepareDatabasePrefix()
+   * @see DrupalTestCase::changeDatabasePrefix()
+   * @see DrupalTestCase::prepareEnvironment()
+   */
+  protected function tearDown() {
+    global $user, $language_interface;
+
+    // In case a fatal error occurred that was not in the test process read the
+    // log to pick up any fatal errors.
+    simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
+
+    $emailCount = count(variable_get('drupal_test_email_collector', array()));
+    if ($emailCount) {
+      $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
+      $this->pass($message, t('E-mail'));
+    }
+
+    // Delete temporary files directory.
+    file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
+
+    // Remove all prefixed tables.
+    $tables = db_find_tables($this->databasePrefix . '%');
+    foreach ($tables as $table) {
+      if (db_drop_table(substr($table, strlen($this->databasePrefix)))) {
+        unset($tables[$table]);
+      }
+    }
+    if (!empty($tables)) {
+      $this->fail('Failed to drop all prefixed tables.');
+    }
+
+    // Get back to the original connection.
+    Database::removeConnection('default');
+    Database::renameConnection('simpletest_original_default', 'default');
+
+    // Restore the original dependency injection container.
+    drupal_container($this->originalContainer);
+
+    // Restore original shutdown callbacks array to prevent original
+    // environment of calling handlers from test run.
+    $callbacks = &drupal_register_shutdown_function();
+    $callbacks = $this->originalShutdownCallbacks;
+
+    // Return the user to the original one.
+    $user = $this->originalUser;
+    drupal_save_session(TRUE);
+
+    // Reset configuration globals.
+    $GLOBALS['config_directory_name'] = $this->originalConfigDirectory;
+    $GLOBALS['config_signature_key'] = $this->originalConfigSignatureKey;
+
+    // Reset public files directory.
+    $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory;
+
+    // Reset language.
+    $language_interface = $this->originalLanguage;
+    if ($this->originalLanguageDefault) {
+      $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
+    }
+  }
+
+  /**
    * Handle errors during test runs.
    *
    * Because this is registered in set_error_handler(), it has to be public.
@@ -706,56 +883,47 @@ class DrupalUnitTestCase extends DrupalTestCase {
   protected function setUp() {
     global $conf;
 
-    // Store necessary current values before switching to the test environment.
-    $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
+    // Create the database prefix for this test.
+    $this->prepareDatabasePrefix();
 
-    // Reset all statics so that test is performed with a clean environment.
-    drupal_static_reset();
+    // Prepare the environment for running tests.
+    $this->prepareEnvironment();
+    $this->originalModuleList = module_list();
 
-    // Generate temporary prefixed database to ensure that tests have a clean starting point.
-    $this->databasePrefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
+    // Empty out module list.
+    $module_list['system']['filename'] = 'core/modules/system/system.module';
+    module_list(TRUE, FALSE, FALSE, $module_list);
+    module_load_all();
 
-    // Create test directory.
-    $public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
-    file_prepare_directory($public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-    $conf['file_public_path'] = $public_files_directory;
+    // Reset all statics and variables to perform tests in a clean environment.
+    $conf = array();
+    drupal_static_reset();
 
-    // Clone the current connection and replace the current prefix.
-    $connection_info = Database::getConnectionInfo('default');
-    Database::renameConnection('default', 'simpletest_original_default');
-    foreach ($connection_info as $target => $value) {
-      $connection_info[$target]['prefix'] = array(
-        'default' => $value['prefix']['default'] . $this->databasePrefix,
-      );
-    }
-    Database::addConnectionInfo('default', 'default', $connection_info['default']);
+    $conf['file_public_path'] = $this->public_files_directory;
+
+    // Change the database prefix.
+    // All static variables need to be reset before the database prefix is
+    // changed, since Drupal\Core\Utility\CacheArray implementations attempt to
+    // write back to persistent caches when they are destructed.
+    $this->changeDatabasePrefix();
 
     // Set user agent to be consistent with web test case.
     $_SERVER['HTTP_USER_AGENT'] = $this->databasePrefix;
 
-    // If locale is enabled then t() will try to access the database and
-    // subsequently will fail as the database is not accessible.
-    $module_list = module_list();
-    if (isset($module_list['locale'])) {
-      $this->originalModuleList = $module_list;
-      unset($module_list['locale']);
-      module_list(TRUE, FALSE, FALSE, $module_list);
-    }
     $this->setup = TRUE;
   }
 
   protected function tearDown() {
     global $conf;
 
-    // Get back to the original connection.
-    Database::removeConnection('default');
-    Database::renameConnection('simpletest_original_default', 'default');
+    parent::tearDown();
 
+    // Restore variables.
     $conf['file_public_path'] = $this->originalFileDirectory;
-    // Restore modules if necessary.
-    if (isset($this->originalModuleList)) {
-      module_list(TRUE, FALSE, FALSE, $this->originalModuleList);
-    }
+
+    // Restore module list.
+    module_list(TRUE, FALSE, FALSE, $this->originalModuleList);
+    module_load_all();
   }
 }
 
@@ -1277,117 +1445,6 @@ class DrupalWebTestCase extends DrupalTestCase {
   }
 
   /**
-   * Generates a database prefix for running tests.
-   *
-   * The generated database table prefix is used for the Drupal installation
-   * being performed for the test. It is also used as user agent HTTP header
-   * value by the cURL-based browser of DrupalWebTestCase, which is sent to the
-   * Drupal installation of the test. During early Drupal bootstrap, the user
-   * agent HTTP header is parsed, and if it matches, all database queries use
-   * the database table prefix that has been generated here.
-   *
-   * @see DrupalWebTestCase::curlInitialize()
-   * @see drupal_valid_test_ua()
-   * @see DrupalWebTestCase::setUp()
-   */
-  protected function prepareDatabasePrefix() {
-    $this->databasePrefix = 'simpletest' . mt_rand(1000, 1000000);
-
-    // As soon as the database prefix is set, the test might start to execute.
-    // All assertions as well as the SimpleTest batch operations are associated
-    // with the testId, so the database prefix has to be associated with it.
-    db_update('simpletest_test_id')
-      ->fields(array('last_prefix' => $this->databasePrefix))
-      ->condition('test_id', $this->testId)
-      ->execute();
-  }
-
-  /**
-   * Changes the database connection to the prefixed one.
-   *
-   * @see DrupalWebTestCase::setUp()
-   */
-  protected function changeDatabasePrefix() {
-    if (empty($this->databasePrefix)) {
-      $this->prepareDatabasePrefix();
-    }
-
-    // Clone the current connection and replace the current prefix.
-    $connection_info = Database::getConnectionInfo('default');
-    Database::renameConnection('default', 'simpletest_original_default');
-    foreach ($connection_info as $target => $value) {
-      $connection_info[$target]['prefix'] = array(
-        'default' => $value['prefix']['default'] . $this->databasePrefix,
-      );
-    }
-    Database::addConnectionInfo('default', 'default', $connection_info['default']);
-  }
-
-  /**
-   * Prepares the current environment for running the test.
-   *
-   * Backups various current environment variables and resets them, so they do
-   * not interfere with the Drupal site installation in which tests are executed
-   * and can be restored in tearDown().
-   *
-   * Also sets up new resources for the testing environment, such as the public
-   * filesystem and configuration directories.
-   *
-   * @see DrupalWebTestCase::setUp()
-   * @see DrupalWebTestCase::tearDown()
-   */
-  protected function prepareEnvironment() {
-    global $user, $language_interface, $conf;
-
-    // Store necessary current values before switching to prefixed database.
-    $this->originalContainer = clone drupal_container();
-    $this->originalLanguage = $language_interface;
-    $this->originalLanguageDefault = variable_get('language_default');
-    $this->originalConfigDirectory = $GLOBALS['config_directory_name'];
-    $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
-    $this->originalProfile = drupal_get_profile();
-    $this->originalUser = $user;
-
-    // Save and clean the shutdown callbacks array because it is static cached
-    // and will be changed by the test run. Otherwise it will contain callbacks
-    // from both environments and the testing environment will try to call the
-    // handlers defined by the original one.
-    $callbacks = &drupal_register_shutdown_function();
-    $this->originalShutdownCallbacks = $callbacks;
-    $callbacks = array();
-
-    // Create test directory ahead of installation so fatal errors and debug
-    // information can be logged during installation process.
-    // Use temporary files directory with the same prefix as the database.
-    $this->public_files_directory = $this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10);
-    $this->private_files_directory = $this->public_files_directory . '/private';
-    $this->temp_files_directory = $this->private_files_directory . '/temp';
-
-    // Create the directories
-    file_prepare_directory($this->public_files_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-    file_prepare_directory($this->private_files_directory, FILE_CREATE_DIRECTORY);
-    file_prepare_directory($this->temp_files_directory, FILE_CREATE_DIRECTORY);
-    $this->generatedTestFiles = FALSE;
-
-    // Create and set a new configuration directory and signature key.
-    // The child site automatically adjusts the global $config_directory_name to
-    // a test-prefix-specific directory within the public files directory.
-    // @see config_get_config_directory()
-    $GLOBALS['config_directory_name'] = 'simpletest/' . substr($this->databasePrefix, 10) . '/config';
-    $this->configFileDirectory = $this->originalFileDirectory . '/' . $GLOBALS['config_directory_name'];
-    file_prepare_directory($this->configFileDirectory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
-
-    // Log fatal errors.
-    ini_set('log_errors', 1);
-    ini_set('error_log', $this->public_files_directory . '/error.log');
-
-    // Set the test information for use in other parts of Drupal.
-    $test_info = &$GLOBALS['drupal_test_info'];
-    $test_info['test_run_id'] = $this->databasePrefix;
-    $test_info['in_child_site'] = FALSE;
-  }
-
-  /**
    * Sets up a Drupal site for running functional and integration tests.
    *
    * Generates a random database prefix and installs Drupal with the specified
@@ -1583,75 +1640,23 @@ class DrupalWebTestCase extends DrupalTestCase {
    * and reset the database prefix.
    */
   protected function tearDown() {
-    global $user, $language_interface;
-
-    // In case a fatal error occurred that was not in the test process read the
-    // log to pick up any fatal errors.
-    simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
-
-    $emailCount = count(variable_get('drupal_test_email_collector', array()));
-    if ($emailCount) {
-      $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
-      $this->pass($message, t('E-mail'));
-    }
-
-    // Delete temporary files directory.
-    file_unmanaged_delete_recursive($this->originalFileDirectory . '/simpletest/' . substr($this->databasePrefix, 10));
-
-    // Remove all prefixed tables.
-    $tables = db_find_tables($this->databasePrefix . '%');
-    foreach ($tables as $table) {
-      if (db_drop_table(substr($table, strlen($this->databasePrefix)))) {
-        unset($tables[$table]);
-      }
-    }
-    if (!empty($tables)) {
-      $this->fail('Failed to drop all prefixed tables.');
-    }
-
-    // Get back to the original connection.
-    Database::removeConnection('default');
-    Database::renameConnection('simpletest_original_default', 'default');
-
-    // Restore the original dependency injection container.
-    drupal_container($this->originalContainer);
-
-    // Restore original shutdown callbacks array to prevent original
-    // environment of calling handlers from test run.
-    $callbacks = &drupal_register_shutdown_function();
-    $callbacks = $this->originalShutdownCallbacks;
-
-    // Return the user to the original one.
-    $user = $this->originalUser;
-    drupal_save_session(TRUE);
-
-    // Ensure that internal logged in variable and cURL options are reset.
-    $this->loggedInUser = FALSE;
-    $this->additionalCurlOptions = array();
+    parent::tearDown();
 
     // Reload module list and implementations to ensure that test module hooks
     // aren't called after tests.
     module_list(TRUE);
     module_implements_reset();
 
+    // Ensure that internal logged in variable and cURL options are reset.
+    $this->loggedInUser = FALSE;
+    $this->additionalCurlOptions = array();
+
     // Reset the Field API.
     field_cache_clear();
 
     // Rebuild caches.
     $this->refreshVariables();
 
-    // Reset public files directory.
-    $GLOBALS['conf']['file_public_path'] = $this->originalFileDirectory;
-
-    // Reset configuration globals.
-    $GLOBALS['config_directory_name'] = $this->originalConfigDirectory;
-
-    // Reset language.
-    $language_interface = $this->originalLanguage;
-    if ($this->originalLanguageDefault) {
-      $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
-    }
-
     // Close the CURL handler.
     $this->curlClose();
   }
