diff --git a/core/includes/common.inc b/core/includes/common.inc
index d6886f2..71224dc 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4754,16 +4754,8 @@ function drupal_flush_all_caches() {
   $module_data = system_rebuild_module_data();
   system_rebuild_theme_data();
 
-  // Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not
-  // sufficient, since the list of enabled modules might have been adjusted
-  // above due to changed code.
-  $files = array();
-  foreach ($module_data as $module => $data) {
-    if (isset($data->uri) && $data->status) {
-      $files[$module] = $data->uri;
-    }
-  }
-  Drupal::service('kernel')->updateModules($module_handler->getModuleList(), $files);
+  Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
+
   // New container, new module handler.
   $module_handler = Drupal::moduleHandler();
 
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 5e8ff4e..bd0752b 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -416,7 +416,7 @@ function update_prepare_d8_bootstrap() {
       update_prepare_d8_language();
       // Rebuild kernel after new language fields are added in the database
       // because the translation service depends on them being there.
-      Drupal::service('kernel')->updateModules($sorted_with_filenames, $sorted_with_filenames);
+      Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
 
       // Change language column to langcode in url_alias.
       if (db_table_exists('url_alias') && db_field_exists('url_alias', 'language')) {
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 8f43e4f..10d3c7d 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -10,6 +10,7 @@
 use Drupal\Component\PhpStorage\PhpStorageFactory;
 use Drupal\Core\Config\BootstrapConfigStorageFactory;
 use Drupal\Core\CoreServiceProvider;
+use Drupal\Core\Extension\ModuleHandlerFactory;
 use Drupal\Core\DependencyInjection\ContainerBuilder;
 use Drupal\Core\DependencyInjection\YamlFileLoader;
 use Symfony\Component\Config\Loader\LoaderInterface;
@@ -60,15 +61,6 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
   protected $booted;
 
   /**
-   * Holds the list of enabled modules.
-   *
-   * @var array
-   *   An associative array whose keys are module names and whose values are
-   *   ignored.
-   */
-  protected $moduleList;
-
-  /**
    * Holds an updated list of enabled modules.
    *
    * @var array
@@ -88,6 +80,13 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
   protected $moduleData = array();
 
   /**
+   * ModuleHandler to get information on installed modules.
+   *
+   * @var \Drupal\Core\Extention/ModuleHandler
+   */
+  protected $moduleHandler;
+
+  /**
    * PHP code storage object to use for the compiled container.
    *
    * @var \Drupal\Component\PhpStorage\PhpStorageInterface
@@ -188,6 +187,9 @@ public function boot() {
     if ($this->booted) {
       return;
     }
+
+    $this->configStorage = BootstrapConfigStorageFactory::get();
+    $this->moduleHandler = ModuleHandlerFactory::create($this->configStorage);
     $this->initializeContainer();
     $this->booted = TRUE;
     if ($this->containerNeedsDumping && !$this->dumpDrupalContainer($this->container, static::CONTAINER_BASE_CLASS)) {
@@ -217,7 +219,6 @@ public function getContainer() {
    * {@inheritdoc}
    */
   public function discoverServiceProviders() {
-    $this->configStorage = BootstrapConfigStorageFactory::get();
     $serviceProviders = array(
       'CoreServiceProvider' => new CoreServiceProvider(),
     );
@@ -226,17 +227,10 @@ public function discoverServiceProviders() {
     );
     $this->serviceProviderClasses = array('Drupal\Core\CoreServiceProvider');
 
-    // Ensure we know what modules are enabled and that their namespaces are
-    // registered.
-    if (!isset($this->moduleList)) {
-      $module_list = $this->configStorage->read('system.module');
-      $this->moduleList = isset($module_list['enabled']) ? $module_list['enabled'] : array();
-    }
-    $module_filenames = $this->getModuleFileNames();
-    $this->registerNamespaces($this->getModuleNamespaces($module_filenames));
+    $this->registerNamespaces($this->moduleHandler->getModuleNamespaces());
 
     // Load each module's serviceProvider class.
-    foreach ($this->moduleList as $module => $weight) {
+    foreach ($this->moduleHandler->getModuleNames() as $module) {
       $camelized = ContainerBuilder::camelize($module);
       $name = "{$camelized}ServiceProvider";
       $class = "Drupal\\{$module}\\{$name}";
@@ -244,7 +238,7 @@ public function discoverServiceProviders() {
         $serviceProviders[$name] = new $class();
         $this->serviceProviderClasses[] = $class;
       }
-      $filename = dirname($module_filenames[$module]) . "/$module.services.yml";
+      $filename = $this->moduleHandler->getModuleDirectory($module) . "/$module.services.yml";
       if (file_exists($filename)) {
         $this->serviceYamls[] = $filename;
       }
@@ -297,53 +291,15 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
   }
 
   /**
-   * Returns module data on the filesystem.
-   *
-   * @param $module
-   *   The name of the module.
-   *
-   * @return \stdClass|bool
-   *   Returns a stdClass object if the module data is found containing at
-   *   least an uri property with the module path, for example
-   *   core/modules/user/user.module.
-   */
-  protected function moduleData($module) {
-    if (!$this->moduleData) {
-      // First, find profiles.
-      $profiles_scanner = new SystemListing();
-      $all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles');
-      $profiles = array_keys(array_intersect_key($this->moduleList, $all_profiles));
-      // If a module is within a profile directory but specifies another
-      // profile for testing, it needs to be found in the parent profile.
-      if (($parent_profile_config = $this->configStorage->read('simpletest.settings')) && isset($parent_profile_config['parent_profile']) && $parent_profile_config['parent_profile'] != $profiles[0]) {
-        // In case both profile directories contain the same extension, the
-        // actual profile always has precedence.
-        array_unshift($profiles, $parent_profile_config['parent_profile']);
-      }
-      // Now find modules.
-      $modules_scanner = new SystemListing($profiles);
-      $this->moduleData = $all_profiles + $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules');
-    }
-    return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE;
-  }
-
-  /**
-   * Implements Drupal\Core\DrupalKernelInterface::updateModules().
-   *
-   * @todo Remove obsolete $module_list parameter. Only $module_filenames is
-   *   needed.
+   * Rebuilds the container during the request. Used when the list of modules
+   * changes.
    */
-  public function updateModules(array $module_list, array $module_filenames = array()) {
-    $this->newModuleList = $module_list;
-    foreach ($module_filenames as $module => $filename) {
-      $this->moduleData[$module] = (object) array('uri' => $filename);
-    }
-    // If we haven't yet booted, we don't need to do anything: the new module
-    // list will take effect when boot() is called. If we have already booted,
-    // then reboot in order to refresh the serviceProvider list and container.
+  public function rebuildContainer() {
+    // If we haven't yet booted, we don't need to do anything. If we have already
+    // booted, then reboot in order to refresh the bundle list and container.
     if ($this->booted) {
-      $this->booted = FALSE;
-      $this->boot();
+      $this->moduleHandler = ModuleHandlerFactory::create($this->configStorage);
+      $this->initializeContainer(TRUE);
     }
   }
 
@@ -380,7 +336,7 @@ protected function getKernelParameters() {
   /**
    * Initializes the service container.
    */
-  protected function initializeContainer() {
+  protected function initializeContainer($rebuild = FALSE) {
     $persist = $this->getServicesToPersist();
     // If we are rebuilding the kernel and we are in a request scope, store
     // request info so we can add them back after the rebuild.
@@ -389,28 +345,15 @@ protected function initializeContainer() {
     }
     $this->container = NULL;
     $class = $this->getClassName();
-    $cache_file = $class . '.php';
 
     if ($this->allowDumping) {
-      // First, try to load.
-      if (!class_exists($class, FALSE)) {
-        $this->storage()->load($cache_file);
-      }
-      // If the load succeeded or the class already existed, use it.
-      if (class_exists($class, FALSE)) {
-        $fully_qualified_class_name = '\\' . $class;
-        $this->container = new $fully_qualified_class_name;
-        $this->persistServices($persist);
-      }
+      $this->container = $this->initializeCachedContainer($class, $persist);
     }
-    // First check whether the list of modules changed in this request.
-    if (isset($this->newModuleList)) {
-      if (isset($this->container) && isset($this->moduleList) && array_keys($this->moduleList) !== array_keys($this->newModuleList)) {
-        unset($this->container);
-      }
-      $this->moduleList = $this->newModuleList;
-      unset($this->newModuleList);
+
+    if ($rebuild) {
+      unset($this->container);
     }
+
     // Second, check if some other request -- for example on another web
     // frontend or during the installer -- changed the list of enabled modules.
     if (isset($this->container)) {
@@ -418,13 +361,9 @@ protected function initializeContainer() {
       // from the container.
       $container_modules = $this->container->getParameter('container.modules');
       $namespaces_before = $this->classLoader->getPrefixes();
-      $this->registerNamespaces($this->getModuleNamespaces($container_modules));
+      $this->registerNamespaces($this->moduleHandler->getModuleNamespaces($container_modules));
 
-      // If 'container.modules' is wrong, the container must be rebuilt.
-      if (!isset($this->moduleList)) {
-        $this->moduleList = $this->container->get('config.factory')->get('system.module')->load()->get('enabled');
-      }
-      if (array_keys($this->moduleList) !== array_keys($container_modules)) {
+      if ($this->moduleHandler->getModuleNames() !== array_keys($container_modules)) {
         $persist = $this->getServicesToPersist();
         unset($this->container);
         // Revert the class loader to its prior state. However,
@@ -439,7 +378,7 @@ protected function initializeContainer() {
 
     if (!isset($this->container)) {
       $this->container = $this->buildContainer();
-      $this->persistServices($persist);
+      $this->persistServices($this->container, $persist);
 
       // The namespaces are marked as persistent, so objects like the annotated
       // class discovery still has the right object. We may have updated the
@@ -462,6 +401,11 @@ protected function initializeContainer() {
       $this->container->enterScope('request');
       $this->container->set('request', $request);
     }
+
+    $this->container->get('event_dispatcher')->addListener(
+      'drupal.update_modules', array($this, 'rebuildContainer')
+    );
+
     \Drupal::setContainer($this->container);
   }
 
@@ -484,12 +428,12 @@ protected function getServicesToPersist() {
   /**
    * Moves persistent service instances into a new container.
    */
-  protected function persistServices(array $persist) {
+  protected function persistServices($container, array $persist) {
     foreach ($persist as $id => $object) {
       // Do not override services already set() on the new container, for
       // example 'service_container'.
-      if (!$this->container->initialized($id)) {
-        $this->container->set($id, $object);
+      if (!$container->initialized($id)) {
+        $container->set($id, $object);
       }
     }
   }
@@ -504,10 +448,10 @@ protected function buildContainer() {
     $container = $this->getContainerBuilder();
     $container->set('kernel', $this);
     $container->setParameter('container.service_providers', $this->serviceProviderClasses);
-    $container->setParameter('container.modules', $this->getModuleFileNames());
+    $container->setParameter('container.modules', $this->moduleHandler->getModuleList());
 
     // Get a list of namespaces and put it onto the container.
-    $namespaces = $this->getModuleNamespaces($this->getModuleFileNames());
+    $namespaces = $this->moduleHandler->getModuleNamespaces();
     // Add all components in \Drupal\Core and \Drupal\Component that have a
     // Plugin directory.
     foreach (array('Core', 'Component') as $parent_directory) {
@@ -634,35 +578,31 @@ protected function storage() {
   }
 
   /**
-   * Returns the file name for each enabled module.
+   * Registers a list of namespaces.
    */
-  protected function getModuleFileNames() {
-    $filenames = array();
-    foreach ($this->moduleList as $module => $weight) {
-      if ($data = $this->moduleData($module)) {
-        $filenames[$module] = $data->uri;
-      }
+  protected function registerNamespaces(array $namespaces = array()) {
+    foreach ($namespaces as $prefix => $path) {
+      $this->classLoader->add($prefix, $path);
     }
-    return $filenames;
   }
 
   /**
-   * Gets the namespaces of each enabled module.
+   * @param $class
+   * @param $persist
    */
-  protected function getModuleNamespaces($moduleFileNames) {
-    $namespaces = array();
-    foreach ($moduleFileNames as $module => $filename) {
-      $namespaces["Drupal\\$module"] = DRUPAL_ROOT . '/' . dirname($filename) . '/lib';
+  protected function initializeCachedContainer($class, $persist) {
+    $container = NULL;
+    $cache_file = $class . '.php';
+    // First, try to load.
+    if (!class_exists($class, FALSE)) {
+      $this->storage()->load($cache_file);
     }
-    return $namespaces;
-  }
-
-  /**
-   * Registers a list of namespaces.
-   */
-  protected function registerNamespaces(array $namespaces = array()) {
-    foreach ($namespaces as $prefix => $path) {
-      $this->classLoader->add($prefix, $path);
+    // If the load succeeded or the class already existed, use it.
+    if (class_exists($class, FALSE)) {
+      $fully_qualified_class_name = '\\' . $class;
+      $container = new $fully_qualified_class_name;
+      $this->persistServices($container, $persist);
     }
+    return $container;
   }
 }
diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php
index 96b2f92..11fda97 100644
--- a/core/lib/Drupal/Core/DrupalKernelInterface.php
+++ b/core/lib/Drupal/Core/DrupalKernelInterface.php
@@ -15,51 +15,5 @@
  * This interface extends Symfony's KernelInterface and adds methods for
  * responding to modules being enabled or disabled during its lifetime.
  */
-interface DrupalKernelInterface extends HttpKernelInterface, \Serializable {
-
-  /**
-   * Boots the current kernel.
-   */
-  public function boot();
-
-  /**
-   * Shuts down the kernel.
-   */
-  public function shutdown();
-
-  /**
-   * Discovers available serviceProviders.
-   *
-   * @return array
-   *   The available serviceProviders.
-   */
-  public function discoverServiceProviders();
-
-  /**
-   * Returns all registered service providers.
-   *
-   * @return array
-   *   An associative array of ServiceProvider objects, keyed by name.
-   */
-  public function getServiceProviders();
-
-  /**
-   * Gets the current container.
-   *
-   * @return ContainerInterface A ContainerInterface instance
-   */
-  public function getContainer();
-
-  /**
-   * Updates the kernel's list of modules to the new list.
-   *
-   * The kernel needs to update its bundle list and container to match the new
-   * list.
-   *
-   * @param array $module_list
-   *   The new list of modules.
-   * @param array $module_filenames
-   *   List of module filenames, keyed by module name.
-   */
-  public function updateModules(array $module_list, array $module_filenames = array());
+interface DrupalKernelInterface extends HttpKernelInterface {
 }
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index b9e5724..2848372 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -65,6 +65,8 @@ class ModuleHandler implements ModuleHandlerInterface {
    */
   protected $alterFunctions;
 
+  protected $moduleData;
+
   /**
    * Constructs a ModuleHandler object.
    *
@@ -141,6 +143,50 @@ public function setModuleList(array $module_list = array()) {
     $this->resetImplementations();
   }
 
+  public function getModuleNames() {
+    return array_keys($this->moduleList);
+  }
+
+  /**
+   * Returns the file name for each enabled module.
+   */
+  public function getModuleFileNames() {
+    return array_values($this->moduleList);
+  }
+
+  public function getModuleFileName($module) {
+    return $this->moduleList[$module];
+  }
+
+  public function getModuleDirectory($module) {
+    return dirname($this->moduleList[$module]);
+  }
+
+  /**
+   * Returns the file name for each enabled module.
+   */
+  public function findModuleFileNames($module_list) {
+    $filenames = array();
+    foreach ($module_list as $module => $weight) {
+      if ($data = $this->moduleData($module, $module_list)) {
+        $filenames[$module] = $data->uri;
+      }
+    }
+    return $filenames;
+  }
+
+  /**
+   * Gets the namespaces of each enabled module.
+   */
+  public function getModuleNamespaces() {
+    $namespaces = array();
+    foreach ($this->getModuleNames() as $module) {
+      $directory = $this->getModuleDirectory($module);
+      $namespaces["Drupal\\$module"] = DRUPAL_ROOT . '/' . $directory . '/lib';
+    }
+    return $namespaces;
+  }
+
   /**
    * Implements \Drupal\Core\Extension\ModuleHandlerInterface::buildModuleDependencies().
    */
@@ -618,8 +664,8 @@ public function enable($module_list, $enable_dependencies = TRUE) {
         // taken over as %container.modules% parameter, which is passed to a fresh
         // ModuleHandler instance upon first retrieval.
         // @todo install_begin_request() creates a container without a kernel.
-        if ($kernel = drupal_container()->get('kernel', ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
-          $kernel->updateModules($module_filenames, $module_filenames);
+        if ($dispatcher = \Drupal::service('event_dispatcher')) {
+          $dispatcher->dispatch('drupal.update_modules');
         }
 
         // Refresh the schema to include it.
@@ -766,9 +812,7 @@ function disable($module_list, $disable_dependents = TRUE) {
       // so we can still call module hooks to get information.
       $this->invokeAll('modules_disabled', array($invoke_modules));
 
-      // Update the kernel to exclude the disabled modules.
-      $enabled = $this->getModuleList();
-      drupal_container()->get('kernel')->updateModules($enabled, $enabled);
+      \Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
 
       // Update the theme registry to remove the newly-disabled module.
       drupal_theme_rebuild();
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerFactory.php b/core/lib/Drupal/Core/Extension/ModuleHandlerFactory.php
new file mode 100644
index 0000000..4edad4f
--- /dev/null
+++ b/core/lib/Drupal/Core/Extension/ModuleHandlerFactory.php
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\Core\Extension\ModuleHandlerFactory.
+ */
+
+namespace Drupal\Core\Extension;
+
+use Drupal\Core\Config\StorageInterface;
+use Drupal\Core\SystemListing;
+
+class ModuleHandlerFactory {
+  protected $moduleData;
+
+  public function __construct(StorageInterface $config_storage) {
+    $this->configStorage = $config_storage;
+  }
+
+  public static function create(StorageInterface $config_storage) {
+    $factory = new static($config_storage);
+    return $factory->get();
+  }
+
+  public function get() {
+    $module_info = $this->configStorage->read('system.module');
+    $enabled_modules = isset($module_info['enabled']) ? $module_info['enabled'] : array();
+    $module_list = $this->findFileNames($enabled_modules);
+    return new ModuleHandler($module_list);
+  }
+
+  /**
+   * Returns the file name for each enabled module.
+   */
+  public function findFileNames($module_list) {
+    $filenames = array();
+    foreach ($module_list as $module => $weight) {
+      if ($data = $this->moduleData($module, $module_list)) {
+        $filenames[$module] = $data->uri;
+      }
+    }
+    return $filenames;
+  }
+
+  /**
+   * Returns module data on the filesystem.
+   *
+   * @param $module
+   *   The name of the module.
+   *
+   * @return \stdClass|bool
+   *   Returns a stdClass object if the module data is found containing at
+   *   least an uri property with the module path, for example
+   *   core/modules/user/user.module.
+   */
+  protected function moduleData($module, $module_list) {
+    if (!$this->moduleData) {
+      $this->buildModuleData($module_list);
+    }
+    return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE;
+  }
+
+  protected function buildModuleData($module_list) {
+    // First, find profiles.
+    $profiles_scanner = new SystemListing();
+    $all_profiles = $profiles_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.profile$/', 'profiles');
+    $profiles = array_keys(array_intersect_key($module_list, $all_profiles));
+    // If a module is within a profile directory but specifies another
+    // profile for testing, it needs to be found in the parent profile.
+    if (($parent_profile_config = $this->configStorage->read('simpletest.settings')) && isset($parent_profile_config['parent_profile']) && $parent_profile_config['parent_profile'] != $profiles[0]) {
+      // In case both profile directories contain the same extension, the
+      // actual profile always has precedence.
+      array_unshift($profiles, $parent_profile_config['parent_profile']);
+    }
+    // Now find modules.
+    $modules_scanner = new SystemListing($profiles);
+    $this->moduleData = $all_profiles + $modules_scanner->scan('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules');
+  }
+}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/ConfigMemoryStorage.php b/core/modules/simpletest/lib/Drupal/simpletest/ConfigMemoryStorage.php
new file mode 100644
index 0000000..87c5f43
--- /dev/null
+++ b/core/modules/simpletest/lib/Drupal/simpletest/ConfigMemoryStorage.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace Drupal\simpletest;
+
+use Drupal\Core\Config\StorageInterface;
+
+class ConfigMemoryStorage implements StorageInterface {
+
+  protected $moduleList;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function exists($name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function read($name) {
+    if ($name == 'system.module') {
+      return $this->moduleList;
+    }
+    return NULL;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function readMultiple(array $names)
+  {
+    return array();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function write($name, array $data) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function delete($name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function rename($name, $new_name) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function encode($data) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function decode($raw) {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function listAll($prefix = '') {
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function deleteAll($prefix = '') {
+  }
+
+  /**
+   * Sets the module list that will be returned to the module handler.
+   *
+   * @param $module_list
+   */
+  public function setModuleList($module_list) {
+    $this->moduleList = $module_list;
+  }
+
+}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
index b55feee..228508b 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
@@ -13,6 +13,7 @@
 use Symfony\Component\DependencyInjection\Reference;
 use Drupal\Core\Database\Database;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Component\Utility\Settings;
 
 /**
  * Base test case class for Drupal unit tests.
@@ -62,6 +63,8 @@
    */
   protected $keyValueFactory;
 
+  protected $bootstrapConfig;
+
   /**
    * Overrides \Drupal\simpletest\UnitTestBase::__construct().
    */
@@ -77,6 +80,7 @@ function __construct($test_id = NULL) {
    * @see DrupalUnitTestBase
    */
   protected function setUp() {
+    $this->bootstrapConfig = new ConfigMemoryStorage();
     // Copy/prime extension file lists once to avoid filesystem scans.
     if (!isset($this->moduleFiles)) {
       $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array();
@@ -95,7 +99,11 @@ protected function setUp() {
     \Drupal::state()->set('system.module.files', $this->moduleFiles);
     \Drupal::state()->set('system.theme.files', $this->themeFiles);
     \Drupal::state()->set('system.theme.data', $this->themeData);
-
+    $settings = settings()->getAll();
+    $settings['drupal_bootstrap_config_storage'] = array($this, 'getBootstrapConfig');
+    // Calling the constructor will update the instance that gets returned for all
+    // future calls to Settings::getSingleton().
+    $settings_object = new Settings($settings);
     // Bootstrap the kernel.
     // No need to dump it; this test runs in-memory.
     $this->kernel = new DrupalKernel('unit_testing', drupal_classloader(), FALSE);
@@ -124,6 +132,10 @@ protected function setUp() {
     \Drupal::config('system.theme')->set('default', 'stark');
   }
 
+  public function getBootstrapConfig() {
+    return $this->bootstrapConfig;
+  }
+
   protected function tearDown() {
     $this->kernel->shutdown();
     parent::tearDown();
@@ -263,13 +275,21 @@ protected function enableModules(array $modules) {
     }
     $module_handler->setModuleList($module_filenames);
     $module_handler->resetImplementations();
+    $module_config = array('enabled' => array());
+    $weight = 0;
+    foreach ($module_filenames as $module => $filename) {
+      $module_config['enabled'][$module] = $weight++;
+    }
+    $this->bootstrapConfig->setModuleList($module_config);
+
     // Update the kernel to make their services available.
-    $this->kernel->updateModules($module_filenames, $module_filenames);
+    \Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
 
     // Ensure isLoaded() is TRUE in order to make theme() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
     // no longer the $module_handler instance from above.
     $module_handler = $this->container->get('module_handler');
+    $module_handler->setModuleList($module_filenames);
     $module_handler->reload();
     $this->pass(format_string('Enabled modules: %modules.', array(
       '%modules' => implode(', ', $modules),
@@ -294,8 +314,14 @@ protected function disableModules(array $modules) {
     }
     $module_handler->setModuleList($module_filenames);
     $module_handler->resetImplementations();
+    $module_config = array('enabled' => array());
+    $weight = 0;
+    foreach ($module_filenames as $module => $filename) {
+      $module_config['enabled'][$module] = $weight++;
+    }
+    $this->bootstrapConfig->setModuleList($module_config);
     // Update the kernel to remove their services.
-    $this->kernel->updateModules($module_filenames, $module_filenames);
+    \Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
 
     // Ensure isLoaded() is TRUE in order to make theme() work.
     // Note that the kernel has rebuilt the container; this $module_handler is
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
index 505ff33..1fbef1e 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php
@@ -51,12 +51,13 @@ function testSetUp() {
    */
   function testEnableModulesLoad() {
     $module = 'field_test';
+    $module_handler = $this->container->get('module_handler');
 
     // Verify that the module does not exist yet.
     $this->assertFalse(module_exists($module), "$module module not found.");
     $list = array_keys(\Drupal::moduleHandler()->getModuleList());
     $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list.");
-    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $list = $module_handler->getImplementations('permission');
     $this->assertFalse(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() not found.");
 
     // Enable the module.
@@ -64,46 +65,13 @@ function testEnableModulesLoad() {
 
     // Verify that the module exists.
     $this->assertTrue(module_exists($module), "$module module found.");
-    $list = array_keys(\Drupal::moduleHandler()->getModuleList());
+    $list = array_keys($module_handler->getModuleList());
     $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list.");
-    $list = \Drupal::moduleHandler()->getImplementations('permission');
+    $list = $module_handler->getImplementations('permission');
     $this->assertTrue(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() found.");
   }
 
   /**
-   * Tests expected installation behavior of enableModules().
-   */
-  function testEnableModulesInstall() {
-    $module = 'node';
-    $table = 'node';
-
-    // Verify that the module does not exist yet.
-    $this->assertFalse(module_exists($module), "$module module not found.");
-    $list = array_keys(\Drupal::moduleHandler()->getModuleList());
-    $this->assertFalse(in_array($module, $list), "$module module not found in the extension handler's module list.");
-    $list = \Drupal::moduleHandler()->getImplementations('permission');
-    $this->assertFalse(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() not found.");
-
-    $this->assertFalse(db_table_exists($table), "'$table' database table not found.");
-    $schema = drupal_get_schema($table);
-    $this->assertFalse($schema, "'$table' table schema not found.");
-
-    // Install the module.
-    module_enable(array($module));
-
-    // Verify that the enabled module exists.
-    $this->assertTrue(module_exists($module), "$module module found.");
-    $list = array_keys(\Drupal::moduleHandler()->getModuleList());
-    $this->assertTrue(in_array($module, $list), "$module module found in the extension handler's module list.");
-    $list = \Drupal::moduleHandler()->getImplementations('permission');
-    $this->assertTrue(in_array($module, $list), "{$module}_permission() in Drupal::moduleHandler()->getImplementations() found.");
-
-    $this->assertTrue(db_table_exists($table), "'$table' database table found.");
-    $schema = drupal_get_schema($table);
-    $this->assertTrue($schema, "'$table' table schema found.");
-  }
-
-  /**
    * Tests installing modules with DependencyInjection services.
    */
   function testEnableModulesInstallContainer() {
@@ -198,28 +166,29 @@ function testInstallConfig() {
    * Tests that the module list is retained after enabling/installing/disabling.
    */
   function testEnableModulesFixedList() {
+    $module_handler = \Drupal::moduleHandler();
     // entity_test is loaded via $modules; its entity type should exist.
-    $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
+    $this->assertEqual($module_handler->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == entity_get_info('entity_test'));
 
     // Load some additional modules; entity_test should still exist.
-    $this->enableModules(array('entity', 'field', 'field_sql_storage', 'text', 'entity_test'));
-    $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
+    $this->enableModules(array('entity', 'field', 'field_sql_storage', 'text', 'entity_test', 'field_test'));
+    $this->assertEqual($module_handler->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == entity_get_info('entity_test'));
 
     // Install some other modules; entity_test should still exist.
-    module_enable(array('field', 'field_sql_storage', 'field_test'), FALSE);
-    $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
+    $module_handler->enable(array('field', 'field_test'), FALSE);
+    $this->assertEqual($module_handler->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == entity_get_info('entity_test'));
 
     // Disable one of those modules; entity_test should still exist.
-    module_disable(array('field_test'));
-    $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
+    $module_handler->disable(array('field_test'));
+    $this->assertEqual($module_handler->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == entity_get_info('entity_test'));
 
     // Set the weight of a module; entity_test should still exist.
     module_set_weight('entity', -1);
-    $this->assertEqual($this->container->get('module_handler')->moduleExists('entity_test'), TRUE);
+    $this->assertEqual($module_handler->moduleExists('entity_test'), TRUE);
     $this->assertTrue(TRUE == entity_get_info('entity_test'));
 
     // Reactivate the disabled module without enabling it.
diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php
index db60d18..a1c273c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php
@@ -9,7 +9,7 @@
 
 use Drupal\Core\DrupalKernel;
 use Drupal\Component\PhpStorage\MTimeProtectedFastFileStorage;
-use Drupal\Component\PhpStorage\FileReadOnlyStorage;
+use Drupal\simpletest\ConfigMemoryStorage;
 use Drupal\simpletest\UnitTestBase;
 use ReflectionClass;
 
@@ -18,6 +18,8 @@
  */
 class DrupalKernelTest extends UnitTestBase {
 
+  protected $bootstrapConfig;
+
   public static function getInfo() {
     return array(
       'name' => 'DrupalKernel tests',
@@ -28,8 +30,10 @@ public static function getInfo() {
 
   function setUp() {
     parent::setUp();
+    $this->bootstrapConfig = new ConfigMemoryStorage();
+    $this->settingsSet('drupal_bootstrap_config_storage', array($this, 'getBootstrapConfig'));
     global $conf;
-    $conf['php_storage']['service_container']= array(
+    $conf['php_storage']['service_container'] = array(
       'bin' => 'service_container',
       'class' => 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage',
       'directory' => DRUPAL_ROOT . '/' . $this->public_files_directory . '/php',
@@ -44,18 +48,20 @@ function setUp() {
    */
   function testCompileDIC() {
     $classloader = drupal_classloader();
-    // @todo: write a memory based storage backend for testing.
     $module_enabled = array(
-      'system' => 'system',
-      'user' => 'user',
+      'system' => 0,
+      'user' => 0,
     );
+    $module_config = array('enabled' => array());
+    foreach ($module_enabled as $module => $weight) {
+      $module_config['enabled'][$module] = $weight;
+    }
+    $this->bootstrapConfig->setModuleList($module_config);
     $kernel = new DrupalKernel('testing', $classloader);
-    $kernel->updateModules($module_enabled);
     $kernel->boot();
     // Instantiate it a second time and we should get the compiled Container
     // class.
     $kernel = new DrupalKernel('testing', $classloader);
-    $kernel->updateModules($module_enabled);
     $kernel->boot();
     $container = $kernel->getContainer();
     $refClass = new ReflectionClass($container);
@@ -69,7 +75,6 @@ function testCompileDIC() {
     global $conf;
     $conf['php_storage']['service_container']['class'] = 'Drupal\Component\PhpStorage\FileReadOnlyStorage';
     $kernel = new DrupalKernel('testing', $classloader);
-    $kernel->updateModules($module_enabled);
     $kernel->boot();
     $container = $kernel->getContainer();
     $refClass = new ReflectionClass($container);
@@ -91,13 +96,17 @@ function testCompileDIC() {
     // Add another module so that we can test that the new module's bundle is
     // registered to the new container.
     $module_enabled['service_provider_test'] = 'service_provider_test';
+    $module_config = array('enabled' => array());
+    foreach ($module_enabled as $module => $weight) {
+      $module_config['enabled'][$module] = $weight;
+    }
+    $this->bootstrapConfig->setModuleList($module_config);
+
     $kernel = new DrupalKernel('testing', $classloader);
-    $kernel->updateModules($module_enabled);
     $kernel->boot();
     // Instantiate it a second time and we should still get a ContainerBuilder
     // class because we are using the read-only PHP storage.
     $kernel = new DrupalKernel('testing', $classloader);
-    $kernel->updateModules($module_enabled);
     $kernel->boot();
     $container = $kernel->getContainer();
     $refClass = new ReflectionClass($container);
@@ -125,4 +134,8 @@ public function testSerialization() {
     $unserialized_kernel = unserialize($string);
     $this->assertTrue($unserialized_kernel instanceof DrupalKernel);
   }
+
+  public function getBootstrapConfig() {
+    return $this->bootstrapConfig;
+  }
 }
diff --git a/core/update.php b/core/update.php
index ac36b2a..a279dcf 100644
--- a/core/update.php
+++ b/core/update.php
@@ -189,7 +189,7 @@ function update_helpful_links() {
  */
 function update_flush_all_caches() {
   unset($GLOBALS['conf']['container_service_providers']['UpdateServiceProvider']);
-  Drupal::service('kernel')->updateModules(Drupal::moduleHandler()->getModuleList());
+  Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
 
   // No updates to run, so caches won't get flushed later.  Clear them now.
   drupal_flush_all_caches();
@@ -356,7 +356,7 @@ function update_access_allowed() {
     $module_filenames['user'] = 'core/modules/user/user.module';
     $module_handler->setModuleList($module_filenames);
     $module_handler->reload();
-    drupal_container()->get('kernel')->updateModules($module_filenames, $module_filenames);
+    Drupal::service('event_dispatcher')->dispatch('drupal.update_modules');
     return user_access('administer software updates');
   }
   catch (\Exception $e) {
