diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index f8300cb..f5c8661 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -80,7 +80,7 @@ public function addUninstallValidator(ModuleUninstallValidatorInterface $uninsta
    * {@inheritdoc}
    */
   public function install(array $module_list, $enable_dependencies = TRUE) {
-    $extension_config = \Drupal::configFactory()->getEditable('core.extension');
+    $extension_config = $this->configFactory()->getEditable('core.extension');
     if ($enable_dependencies) {
       // Get all module data so we can find dependencies and sort.
       $module_data = system_rebuild_module_data();
@@ -126,11 +126,9 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
     // Required for module installation checks.
     include_once $this->root . '/core/includes/install.inc';
 
-    /** @var \Drupal\Core\Config\ConfigInstaller $config_installer */
-    $config_installer = \Drupal::service('config.installer');
-    $sync_status = $config_installer->isSyncing();
+    $sync_status = $this->configInstaller()->isSyncing();
     if ($sync_status) {
-      $source_storage = $config_installer->getSourceStorage();
+      $source_storage = $this->configInstaller()->getSourceStorage();
     }
     $modules_installed = array();
     foreach ($module_list as $module) {
@@ -143,7 +141,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
 
         // Check the validity of the default configuration. This will throw
         // exceptions if the configuration is not valid.
-        $config_installer->checkConfigurationToInstall('module', $module);
+        $this->configInstaller()->checkConfigurationToInstall('module', $module);
 
         // Save this data without checking schema. This is a performance
         // improvement for module installation.
@@ -202,7 +200,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         drupal_install_schema($module);
 
         // Clear plugin manager caches.
-        \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
+        $this->pluginCacheClearer()->clearCachedDefinitions();
 
         // Set the schema version to the number of the last update provided by
         // the module, or the minimum core schema version.
@@ -217,9 +215,8 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         // handler can use this as an opportunity to create the necessary
         // database tables.
         // @todo Clean this up in https://www.drupal.org/node/2350111.
-        $entity_manager = \Drupal::entityManager();
-        $update_manager = \Drupal::entityDefinitionUpdateManager();
-        foreach ($entity_manager->getDefinitions() as $entity_type) {
+        $update_manager = $this->entityDefinitionUpdateManager();
+        foreach ($this->entityTypeManager()->getDefinitions() as $entity_type) {
           if ($entity_type->getProvider() == $module) {
             $update_manager->installEntityType($entity_type);
           }
@@ -227,7 +224,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
             // The module being installed may be adding new fields to existing
             // entity types. Field definitions for any entity type defined by
             // the module are handled in the if branch.
-            foreach ($entity_manager->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
+            foreach ($this->entityFieldManager()->getFieldStorageDefinitions($entity_type->id()) as $storage_definition) {
               if ($storage_definition->getProvider() == $module) {
                 // If the module being installed is also defining a storage key
                 // for the entity type, the entity schema may not exist yet. It
@@ -244,13 +241,12 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         }
 
         // Install default configuration of the module.
-        $config_installer = \Drupal::service('config.installer');
         if ($sync_status) {
-          $config_installer
+          $this->configInstaller()
             ->setSyncing(TRUE)
             ->setSourceStorage($source_storage);
         }
-        \Drupal::service('config.installer')->installDefaultConfig('module', $module);
+        $this->configInstaller()->installDefaultConfig('module', $module);
 
         // If the module has no current updates, but has some that were
         // previously removed, set the version to the value of
@@ -261,8 +257,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         drupal_set_installed_schema_version($module, $version);
 
         // Ensure that all post_update functions are registered already.
-        /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
-        $post_update_registry = \Drupal::service('update.post_update_registry');
+        $post_update_registry = $this->postUpdateRegistry();
         $post_update_registry->registerInvokedUpdates($post_update_registry->getModuleUpdateFunctions($module));
 
         // Record the fact that it was installed.
@@ -273,28 +268,25 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
         // particular, this happens when installing Drupal via Drush, as the
         // 'translations' stream wrapper is provided by Interface Translation
         // module and is later used to import translations.
-        \Drupal::service('stream_wrapper_manager')->register();
+        $this->streamWrapperManager()->register();
 
         // Update the theme registry to include it.
         drupal_theme_rebuild();
 
         // Modules can alter theme info, so refresh theme data.
-        // @todo ThemeHandler cannot be injected into ModuleHandler, since that
-        //   causes a circular service dependency.
-        // @see https://www.drupal.org/node/2208429
-        \Drupal::service('theme_handler')->refreshInfo();
+        $this->themeHandler()->refreshInfo();
 
         // Allow the module to perform install tasks.
         $this->moduleHandler->invoke($module, 'install');
 
         // Record the fact that it was installed.
-        \Drupal::logger('system')->info('%module module installed.', array('%module' => $module));
+        $this->loggerFactory()->get('system')->info('%module module installed.', array('%module' => $module));
       }
     }
 
     // If any modules were newly installed, invoke hook_modules_installed().
     if (!empty($modules_installed)) {
-      \Drupal::service('router.builder')->setRebuildNeeded();
+      $this->routeBuilder()->setRebuildNeeded();
       $this->moduleHandler->invokeAll('modules_installed', array($modules_installed));
     }
 
@@ -313,7 +305,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       return FALSE;
     }
 
-    $extension_config = \Drupal::configFactory()->getEditable('core.extension');
+    $extension_config = $this->configFactory()->getEditable('core.extension');
     $installed_modules = $extension_config->get('module') ?: array();
     if (!$module_list = array_intersect_key($module_list, $installed_modules)) {
       // Nothing to do. All modules already uninstalled.
@@ -364,11 +356,10 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       // Clean up all entity bundles (including fields) of every entity type
       // provided by the module that is being uninstalled.
       // @todo Clean this up in https://www.drupal.org/node/2350111.
-      $entity_manager = \Drupal::entityManager();
-      foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
+      foreach ($this->entityTypeManager()->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->getProvider() == $module) {
-          foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) {
-            $entity_manager->onBundleDelete($bundle, $entity_type_id);
+          foreach (array_keys($this->entityTypeBundleInfo()->getBundleInfo($entity_type_id)) as $bundle) {
+            $this->entityBundleListener()->onBundleDelete($bundle, $entity_type_id);
           }
         }
       }
@@ -381,14 +372,14 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       $this->moduleHandler->invoke($module, 'uninstall');
 
       // Remove all configuration belonging to the module.
-      \Drupal::service('config.manager')->uninstall('module', $module);
+      $this->configManager()->uninstall('module', $module);
 
       // Notify interested components that this module's entity types are being
       // deleted. For example, a SQL-based storage handler can use this as an
       // opportunity to drop the corresponding database tables.
       // @todo Clean this up in https://www.drupal.org/node/2350111.
-      $update_manager = \Drupal::entityDefinitionUpdateManager();
-      foreach ($entity_manager->getDefinitions() as $entity_type) {
+      $update_manager = $this->entityDefinitionUpdateManager();
+      foreach ($this->entityTypeManager()->getDefinitions() as $entity_type) {
         if ($entity_type->getProvider() == $module) {
           $update_manager->uninstallEntityType($entity_type);
         }
@@ -398,8 +389,8 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
           // the module are handled in the if branch.
           $entity_type_id = $entity_type->id();
           /** @var \Drupal\Core\Entity\FieldableEntityStorageInterface $storage */
-          $storage = $entity_manager->getStorage($entity_type_id);
-          foreach ($entity_manager->getFieldStorageDefinitions($entity_type_id) as $storage_definition) {
+          $storage = $this->entityTypeManager()->getStorage($entity_type_id);
+          foreach ($this->entityFieldManager()->getFieldStorageDefinitions($entity_type_id) as $storage_definition) {
             // @todo We need to trigger field purging here.
             //   See https://www.drupal.org/node/2282119.
             if ($storage_definition->getProvider() == $module && !$storage->countFieldData($storage_definition, TRUE)) {
@@ -414,7 +405,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
 
       // Remove the module's entry from the config. Don't check schema when
       // uninstalling a module since we are only clearing a key.
-      \Drupal::configFactory()->getEditable('core.extension')->clear("module.$module")->save(TRUE);
+      $this->configFactory()->getEditable('core.extension')->clear("module.$module")->save(TRUE);
 
       // Update the module handler to remove the module.
       // The current ModuleHandler instance is obsolete with the kernel rebuild
@@ -432,7 +423,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       drupal_static_reset('system_rebuild_module_data');
 
       // Clear plugin manager caches.
-      \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
+      $this->pluginCacheClearer()->clearCachedDefinitions();
 
       // Update the kernel to exclude the uninstalled modules.
       $this->updateKernel($module_filenames);
@@ -444,18 +435,17 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
       // @todo ThemeHandler cannot be injected into ModuleHandler, since that
       //   causes a circular service dependency.
       // @see https://www.drupal.org/node/2208429
-      \Drupal::service('theme_handler')->refreshInfo();
+      $this->themeHandler()->refreshInfo();
 
-      \Drupal::logger('system')->info('%module module uninstalled.', array('%module' => $module));
+      $this->loggerFactory()->get('system')->info('%module module uninstalled.', array('%module' => $module));
 
-      $schema_store = \Drupal::keyValue('system.schema');
+      $schema_store = $this->keyValueFactory()->get('system.schema');
       $schema_store->delete($module);
 
-      /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
-      $post_update_registry = \Drupal::service('update.post_update_registry');
+      $post_update_registry = $this->postUpdateRegistry();
       $post_update_registry->filterOutInvokedUpdatesByModule($module);
     }
-    \Drupal::service('router.builder')->setRebuildNeeded();
+    $this->routeBuilder()->setRebuildNeeded();
     drupal_get_installed_schema_version(NULL, TRUE);
 
     // Let other modules react.
@@ -484,6 +474,7 @@ protected function removeCacheBins($module) {
     if (file_exists($service_yaml_file)) {
       $definitions = Yaml::decode(file_get_contents($service_yaml_file));
       if (isset($definitions['services'])) {
+        $container = \Drupal::getContainer();
         foreach ($definitions['services'] as $id => $definition) {
           if (isset($definition['tags'])) {
             foreach ($definition['tags'] as $tag) {
@@ -492,7 +483,7 @@ protected function removeCacheBins($module) {
               // be extremely rare.
               if ($tag['name'] == 'cache.bin' && isset($definition['factory_service']) && isset($definition['factory_method']) && !empty($definition['arguments'])) {
                 try {
-                  $factory = \Drupal::service($definition['factory_service']);
+                  $factory = $container->get($definition['factory_service']);
                   if (method_exists($factory, $definition['factory_method'])) {
                     $backend = call_user_func_array(array($factory, $definition['factory_method']), $definition['arguments']);
                     if ($backend instanceof CacheBackendInterface) {
@@ -548,4 +539,143 @@ public function validateUninstall(array $module_list) {
     return $reasons;
   }
 
+  /**
+   * Wraps the config factory service.
+   *
+   * @return \Drupal\Core\Config\ConfigFactoryInterface
+   */
+  protected function configFactory() {
+    return \Drupal::configFactory();
+  }
+
+  /**
+   * Wraps the config installer service.
+   *
+   * @return \Drupal\Core\Config\ConfigInstallerInterface
+   */
+  protected function configInstaller() {
+    return \Drupal::service('config.installer');
+  }
+
+  /**
+   * Wraps the config manager service.
+   *
+   * @return \Drupal\Core\Config\ConfigManagerInterface
+   */
+  protected function configManager() {
+    return \Drupal::service('config.manager');
+  }
+
+  /**
+   * Wraps the plugin cache clearer service.
+   *
+   * @return \Drupal\Core\Plugin\CachedDiscoveryClearerInterface
+   */
+  protected function pluginCacheClearer() {
+    return \Drupal::service('plugin.cache_clearer');
+  }
+
+  /**
+   * Wraps the entity type manager service.
+   *
+   * @return \Drupal\Core\Entity\EntityTypeManagerInterface
+   */
+  protected function entityTypeManager() {
+    return \Drupal::entityTypeManager();
+  }
+
+  /**
+   * Wraps the entity definition update manager service.
+   *
+   * @return \Drupal\Core\Entity\EntityDefinitionUpdateManagerInterface
+   */
+  protected function entityDefinitionUpdateManager() {
+    return \Drupal::entityDefinitionUpdateManager();
+  }
+
+  /**
+   * Wraps the entity field manager service.
+   *
+   * @return \Drupal\Core\Entity\EntityFieldManagerInterface
+   */
+  protected function entityFieldManager() {
+    return \Drupal::service('entity_field.manager');
+  }
+
+  /**
+   * Wraps the entity type bundle info service.
+   *
+   * @return \Drupal\Core\Entity\EntityTypeBundleInfoInterface
+   */
+  protected function entityTypeBundleInfo() {
+    return \Drupal::service('entity_type.bundle.info');
+  }
+
+  /**
+   * Wraps the entity bundle listener service.
+   *
+   * @return \Drupal\Core\Entity\EntityBundleListenerInterface
+   */
+  protected function entityBundleListener() {
+    return \Drupal::service('entity_bundle.listener');
+  }
+
+  /**
+   * Wraps the post update registry service.
+   *
+   * @return \Drupal\Core\Update\UpdateRegistry
+   */
+  protected function postUpdateRegistry() {
+    return \Drupal::service('update.post_update_registry');
+  }
+
+  /**
+   * Wraps the stream wrapper manager service.
+   *
+   * @return \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface
+   */
+  protected function streamWrapperManager() {
+    return \Drupal::service('stream_wrapper_manager');
+  }
+
+  /**
+   * Wraps the theme handler service.
+   *
+   * @return \Drupal\Core\Extension\ThemeHandlerInterface
+   *
+   * @todo ThemeHandler cannot be injected into ModuleHandler, since that
+   *   causes a circular service dependency.
+   * @see https://www.drupal.org/node/2208429
+   */
+  protected function themeHandler() {
+    return \Drupal::service('theme_handler');
+  }
+
+  /**
+   * Wraps the route builder service.
+   *
+   * @return \Drupal\Core\Routing\RouteBuilderInterface
+   */
+  protected function routeBuilder() {
+    return \Drupal::service('router.builder');
+  }
+
+  /**
+   * Wraps the logger factory service.
+   *
+   * @return \Drupal\Core\Logger\LoggerChannelFactoryInterface
+   */
+  protected function loggerFactory() {
+    return \Drupal::service('logger.factory');
+  }
+
+  /**
+   * Wraps the key/value factory service.
+   *
+   * @return \Drupal\Core\KeyValueStore\KeyValueFactoryInterface
+   */
+  protected function keyValueFactory() {
+    return \Drupal::service('keyvalue');
+  }
+
 }
