diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index f8300cb..09e87fe 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -76,11 +76,57 @@ public function addUninstallValidator(ModuleUninstallValidatorInterface $uninsta
     $this->uninstallValidators[] = $uninstall_validator;
   }
 
+  protected function configFactory() {
+    return \Drupal::configFactory();
+  }
+  protected function configInstaller() {
+    return \Drupal::service('config.installer');
+  }
+  protected function pluginCacheClearer() {
+    return \Drupal::service('plugin.cache_clearer');
+  }
+  protected function entityTypeManager() {
+    return \Drupal::entityTypeManager();
+  }
+  protected function entityDefinitionUpdateManager() {
+    return \Drupal::entityDefinitionUpdateManager();
+  }
+  protected function entityFieldManager() {
+    return \Drupal::service('entity_field.manager');
+  }
+  protected function postUpdateRegistry() {
+    return \Drupal::service('update.post_update_registry');
+  }
+  protected function streamWrapperManager() {
+    return \Drupal::service('stream_wrapper_manager');
+  }
+  protected function themeHandler() {
+    return \Drupal::service('theme_handler');
+  }
+  protected function routerBuilder() {
+    return \Drupal::service('router.builder');
+  }
+  protected function entityTypeBundleInfo() {
+    return \Drupal::service('entity_type.bundle.info');
+  }
+  protected function entityBundleListener() {
+    return \Drupal::service('entity_bundle.listener');
+  }
+  protected function configManager() {
+    return \Drupal::service('config.manager');
+  }
+  protected function loggerFactory() {
+    return \Drupal::service('logger.factory');
+  }
+  protected function keyValueFactory() {
+    return \Drupal::service('keyvalue');
+  }
+
   /**
    * {@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 +172,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 +187,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 +246,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 +261,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 +270,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 +287,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 +303,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,7 +314,7 @@ 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();
@@ -282,19 +323,19 @@ public function install(array $module_list, $enable_dependencies = 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();
 
         // 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->routerBuilder()->setRebuildNeeded();
       $this->moduleHandler->invokeAll('modules_installed', array($modules_installed));
     }
 
@@ -313,7 +354,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 +405,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 +421,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 +438,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 +454,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 +472,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 +484,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->routerBuilder()->setRebuildNeeded();
     drupal_get_installed_schema_version(NULL, TRUE);
 
     // Let other modules react.
@@ -484,6 +523,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 +532,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) {
