diff --git includes/module.inc includes/module.inc
index 40ba029..1ccc1f3 100644
--- includes/module.inc
+++ includes/module.inc
@@ -293,12 +293,11 @@ function module_load_all_includes($type, $name = NULL) {
  *   If TRUE, dependencies will automatically be added and enabled in the
  *   correct order. This incurs a significant performance cost, so use FALSE
  *   if you know $module_list is already complete and in the correct order.
- * @param $disable_modules_installed_hook
- *   Normally just testing wants to set this to TRUE.
+ *
  * @return
  *   FALSE if one or more dependencies are missing, TRUE otherwise.
  */
-function module_enable($module_list, $enable_dependencies = TRUE, $disable_modules_installed_hook = FALSE) {
+function module_enable($module_list, $enable_dependencies = TRUE) {
   if ($enable_dependencies) {
     // Get all module data so we can find dependencies and sort.
     $module_data = system_rebuild_module_data();
@@ -392,7 +391,7 @@ function module_enable($module_list, $enable_dependencies = TRUE, $disable_modul
   }
 
   // If any modules were newly installed, invoke hook_modules_installed().
-  if (!$disable_modules_installed_hook && !empty($modules_installed)) {
+  if (!empty($modules_installed)) {
     module_invoke_all('modules_installed', $modules_installed);
   }
 
diff --git includes/theme.inc includes/theme.inc
index d3e48db..227309b 100644
--- includes/theme.inc
+++ includes/theme.inc
@@ -561,7 +561,7 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) {
  *   - 'base theme': The name of the base theme.
  */
 function list_themes($refresh = FALSE) {
-  static $list = array();
+  $list = &drupal_static(__FUNCTION__, array());
 
   if ($refresh) {
     $list = array();
diff --git modules/rdf/rdf.module modules/rdf/rdf.module
index fa76bb2..7e350c6 100644
--- modules/rdf/rdf.module
+++ modules/rdf/rdf.module
@@ -267,10 +267,6 @@ function rdf_rdfa_attributes($mapping, $data = NULL) {
  * database so that they can be altered via the RDF CRUD mapping API.
  */
 function rdf_modules_installed($modules) {
-  // We need to clear the caches of entity_info as this is not done right
-  // during the tests. see http://drupal.org/node/594234
-  entity_info_cache_clear();
-
   foreach ($modules as $module) {
     $function = $module . '_rdf_mapping';
     if (function_exists($function)) {
diff --git modules/rdf/rdf.test modules/rdf/rdf.test
index 97bb103..955947b 100644
--- modules/rdf/rdf.test
+++ modules/rdf/rdf.test
@@ -17,9 +17,6 @@ class RdfMappingHookTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('rdf', 'rdf_test', 'field_test');
-    // We need to trigger rdf_modules_installed() because
-    // hook_modules_installed() is not automatically invoked during testing.
-    rdf_modules_installed(array('rdf_test'));
   }
 
   /**
@@ -53,7 +50,6 @@ class RdfMarkupTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('rdf', 'field_test', 'rdf_test');
-    rdf_modules_installed(array('field_test', 'rdf_test'));
   }
 
   /**
@@ -196,13 +192,14 @@ class RdfCrudTestCase extends DrupalWebTestCase {
     $test_mapping = rdf_test_rdf_mapping();
 
     // Verify loading of a default mapping.
-    $this->assertFalse(count(_rdf_mapping_load('test_entity', 'test_bundle')), t('Default mapping was found.'));
+    $mapping = _rdf_mapping_load('test_entity', 'test_bundle');
+    $this->assertTrue(count($mapping), t('Default mapping was found.'));
 
     // Verify saving a mapping.
     $mapping = (array) $test_mapping;
     rdf_mapping_save($mapping[0]);
     $this->assertEqual($mapping[0]['mapping'], $test_mapping[0]['mapping'], t('Saved mapping equals default mapping.'));
-    $this->assertTrue(rdf_mapping_save($mapping[1]) === SAVED_NEW, t('Second mapping was inserted.'));
+    rdf_mapping_save($mapping[1]);
     $this->assertEqual($mapping[1]['mapping'], _rdf_mapping_load($test_mapping[1]['type'], $test_mapping[1]['bundle']), t('Second mapping equals default mapping.'));
 
     // Verify loading of saved mapping.
@@ -232,12 +229,6 @@ class RdfMappingDefinitionTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('rdf', 'rdf_test', 'blog');
-    // We need to trigger rdf_modules_installed() because
-    // hook_modules_installed() is not automatically invoked during testing.
-    rdf_modules_installed(array('rdf_test', 'node'));
-    // entity_info caches must be cleared during testing. This is done
-    // automatically during the manual installation.
-    entity_info_cache_clear();
   }
 
   /**
@@ -327,13 +318,6 @@ class RdfTrackerAttributesTestCase extends DrupalWebTestCase {
 
   function setUp() {
     parent::setUp('rdf', 'rdf_test', 'tracker');
-    // We need to trigger rdf_modules_installed() because
-    // hook_modules_installed() is not automatically invoked during testing.
-    rdf_modules_installed(array('rdf_test', 'node'));
-    // entity_info caches must be cleared during testing. This is done
-    // automatically during the manual installation.
-    cache_clear_all('entity_info', 'cache');
-    drupal_static_reset('entity_get_info');
     // Enable anonymous posting of content.
     user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
       'create article content' => TRUE,
diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php
index 6727433..7cddebc 100644
--- modules/simpletest/drupal_web_test_case.php
+++ modules/simpletest/drupal_web_test_case.php
@@ -547,8 +547,7 @@ abstract class DrupalTestCase {
  *
  * These tests can not access the database nor files. Calling any Drupal
  * function that needs the database will throw exceptions. These include
- * watchdog(), function_exists(), module_implements(),
- * module_invoke_all() etc.
+ * watchdog(), module_implements(), module_invoke_all() etc.
  */
 class DrupalUnitTestCase extends DrupalTestCase {
 
@@ -1124,8 +1123,7 @@ class DrupalWebTestCase extends DrupalTestCase {
     ini_set('log_errors', 1);
     ini_set('error_log', $public_files_directory . '/error.log');
 
-    // Reset all statics and variables so that test is performed with a clean
-    // environment.
+    // Reset all statics and variables to perform tests in a clean environment.
     $conf = array();
     drupal_static_reset();
 
@@ -1139,32 +1137,30 @@ class DrupalWebTestCase extends DrupalTestCase {
     $profile_details = install_profile_info('standard', 'en');
 
     // Install the modules specified by the default profile.
-    module_enable($profile_details['dependencies'], FALSE, TRUE);
-
-    drupal_static_reset('_node_types_build');
+    module_enable($profile_details['dependencies'], FALSE);
 
+    // Install modules needed for this test.
     if ($modules = func_get_args()) {
-      // Install modules needed for this test.
-      module_enable($modules, TRUE, TRUE);
+      module_enable($modules, TRUE);
     }
 
-    // Because the schema is static cached, we need to flush
-    // it between each run. If we don't, then it will contain
-    // stale data for the previous run's database prefix and all
-    // calls to it will fail.
-    drupal_get_schema(NULL, TRUE);
-
     // Run default profile tasks.
-    $install_state = array();
-    module_enable(array('standard'), FALSE, TRUE);
+    module_enable(array('standard'), FALSE);
 
     // Rebuild caches.
-    node_types_rebuild();
+    drupal_static_reset();
+    drupal_flush_all_caches();
+
+    // Register actions declared by any modules.
     actions_synchronize();
-    _drupal_flush_css_js();
+
+    // Reload global $conf array and permissions.
     $this->refreshVariables();
     $this->checkPermissions(array(), TRUE);
 
+    // Reset statically cached schema for new database prefix.
+    drupal_get_schema(NULL, TRUE);
+
     // Run cron once in that environment, as install.php does at the end of
     // the installation process.
     drupal_cron_run();
