diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php
index 537a844..ea2c631 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php
@@ -183,7 +183,10 @@ public function addProfile($name, $path) {
    */
   protected function add($type, $name, $path) {
     $pathname = "$path/$name.info.yml";
-    $filename = file_exists("$path/$name.$type") ? "$name.$type" : NULL;
+    if (!file_exists($this->getAppRoot() . "/$pathname")) {
+      throw new \InvalidArgumentException("Unknown $type: $pathname not found.");
+    }
+    $filename = file_exists($this->getAppRoot() . "/$path/$name.$type") ? "$name.$type" : NULL;
     $this->moduleList[$name] = new Extension($type, $pathname, $filename);
     $this->resetImplementations();
   }
@@ -233,12 +236,12 @@ public function loadAllIncludes($type, $name = NULL) {
   public function loadInclude($module, $type, $name = NULL) {
     if ($type == 'install') {
       // Make sure the installation API is available
-      include_once DRUPAL_ROOT . '/core/includes/install.inc';
+      include_once $this->getAppRoot() . '/core/includes/install.inc';
     }
 
     $name = $name ?: $module;
     if (isset($this->moduleList[$module])) {
-      $file = DRUPAL_ROOT . '/' . $this->moduleList[$module]->getPath() . "/$name.$type";
+      $file = $this->getAppRoot() . '/' . $this->moduleList[$module]->getPath() . "/$name.$type";
       if (is_file($file)) {
         require_once $file;
         return $file;
@@ -681,7 +684,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) {
     }
 
     // Required for module installation checks.
-    include_once DRUPAL_ROOT . '/core/includes/install.inc';
+    include_once $this->getAppRoot() . '/core/includes/install.inc';
 
     /** @var \Drupal\Core\Config\ConfigInstaller $config_installer */
     $config_installer = \Drupal::service('config.installer');
@@ -974,9 +977,18 @@ protected function removeCacheBins($module) {
   public function getModuleDirectories() {
     $dirs = array();
     foreach ($this->getModuleList() as $name => $module) {
-      $dirs[$name] = DRUPAL_ROOT . '/' . $module->getPath();
+      $dirs[$name] = $this->getAppRoot() . '/' . $module->getPath();
     }
     return $dirs;
   }
 
+  /**
+   * Returns the absolute path to the application's root directory.
+   *
+   * @return string
+   */
+  protected function getAppRoot() {
+    return DRUPAL_ROOT;
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
index 6406698..020814f 100644
--- a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
+++ b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php
@@ -73,6 +73,9 @@ public function setModuleList(array $module_list = array());
    *   The module name; e.g., 'node'.
    * @param string $path
    *   The module path; e.g., 'core/modules/node'.
+   *
+   * @throws \InvalidArgumentException
+   *   If the specified module path does not exist.
    */
   public function addModule($name, $path);
 
@@ -83,6 +86,9 @@ public function addModule($name, $path);
    *   The profile name; e.g., 'standard'.
    * @param string $path
    *   The profile path; e.g., 'core/profiles/standard'.
+   *
+   * @throws \InvalidArgumentException
+   *   If the specified installation profile path does not exist.
    */
   public function addProfile($name, $path);
 
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
index eb0477f..de80575 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityFormDisplayTest.php
@@ -181,7 +181,7 @@ public function testBaseFieldComponent() {
    * Tests deleting field instance.
    */
   public function testDeleteFieldInstance() {
-    $this->enableModules(array('field_sql_storage', 'field_test'));
+    $this->enableModules(array('field_test'));
 
     $field_name = 'test_field';
     // Create a field and an instance.
diff --git a/core/modules/field/lib/Drupal/field/Tests/Email/EmailItemTest.php b/core/modules/field/lib/Drupal/field/Tests/Email/EmailItemTest.php
index 8aa560b..fd76b66 100644
--- a/core/modules/field/lib/Drupal/field/Tests/Email/EmailItemTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/Email/EmailItemTest.php
@@ -21,7 +21,7 @@ class EmailItemTest extends FieldUnitTestBase {
    *
    * @var array
    */
-  public static $modules = array('email');
+  public static $modules = array('text');
 
   public static function getInfo() {
     return array(
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/EmailFieldRdfaTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/EmailFieldRdfaTest.php
index fa9775f..5d483a3 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/Field/EmailFieldRdfaTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/Field/EmailFieldRdfaTest.php
@@ -21,7 +21,7 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
   /**
    * {@inheritdoc}
    */
-  public static $modules = array('email', 'text');
+  public static $modules = array('text');
 
   public static function getInfo() {
     return array(
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
index c0228ba..35f9921 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
@@ -29,7 +29,7 @@
  */
 class ViewExecutableTest extends ViewUnitTestBase {
 
-  public static $modules = array('system', 'node', 'comment', 'user', 'filter', 'entity', 'field', 'field_sql_storage', 'text');
+  public static $modules = array('system', 'node', 'comment', 'user', 'filter', 'entity', 'field', 'text');
 
   /**
    * Views used by this test.
diff --git a/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
new file mode 100644
index 0000000..1371bb8
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php
@@ -0,0 +1,128 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\Core\Extension\ModuleHandlerTest.
+ */
+
+namespace Drupal\Tests\Core\Extension;
+
+use Drupal\Core\Extension\ModuleHandler;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Tests the module handler.
+ *
+ * @group Drupal
+ * @group Extension
+ *
+ * @coversDefaultClass \Drupal\Core\Extension\ModuleHandler
+ */
+class ModuleHandlerTest extends UnitTestCase {
+
+  /**
+   * The cache backend.
+   *
+   * @var \Drupal\Core\Cache\CacheBackendInterface|\PHPUnit_Framework_MockObject_MockObject
+   */
+  protected $cacheBackend;
+
+  /**
+   * The module handler.
+   *
+   * @var \Drupal\Core\Extension\ModuleHandler
+   */
+  protected $moduleHandler;
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Module handler',
+      'description' => 'Tests the module handler.',
+      'group' => 'Module',
+    );
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    $this->cacheBackend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface');
+
+    $this->moduleHandler = new TestModuleHandler(array(), $this->cacheBackend, __DIR__);
+  }
+
+  /**
+   * Tests adding a module.
+   *
+   * @covers ::addModule
+   * @covers ::add
+   */
+  public function testAddModule() {
+    $this->cacheBackend->expects($this->once())
+      ->method('set')
+      ->with('module_implements', array());
+    $this->cacheBackend->expects($this->once())
+      ->method('delete')
+      ->with('hook_info');
+
+    $this->moduleHandler->addModule('module_handler_test', 'modules/module_handler_test');
+    $this->assertTrue($this->moduleHandler->moduleExists('module_handler_test'));
+  }
+
+  /**
+   * Tests adding a non-existing module.
+   *
+   * @expectedException \InvalidArgumentException
+   * @expectedExceptionMessage Unknown module: modules/non_existing/name.info.yml not found.
+   *
+   * @covers ::addModule
+   * @covers ::add
+   */
+  public function testAddModuleNonExisting() {
+    $this->moduleHandler->addModule('name', 'modules/non_existing');
+  }
+
+  /**
+   * Tests adding a profile.
+   *
+   * @covers ::addProfile
+   * @covers ::add
+   */
+  public function testAddProfile() {
+    $this->cacheBackend->expects($this->once())
+      ->method('set')
+      ->with('module_implements', array());
+    $this->cacheBackend->expects($this->once())
+      ->method('delete')
+      ->with('hook_info');
+
+    $this->moduleHandler->addProfile('module_handler_test', 'modules/module_handler_test');
+    $this->assertTrue($this->moduleHandler->moduleExists('module_handler_test'));
+  }
+
+  /**
+   * Tests adding a non-existing installation profile.
+   *
+   * @expectedException \InvalidArgumentException
+   * @expectedExceptionMessage Unknown profile: profiles/non_existing/name.info.yml not found.
+   *
+   * @covers ::addProfile
+   * @covers ::add
+   */
+  public function testAddProfileNonExisting() {
+    $this->moduleHandler->addProfile('name', 'profiles/non_existing');
+  }
+
+}
+
+class TestModuleHandler extends ModuleHandler {
+
+  protected function getAppRoot() {
+    return __DIR__;
+  }
+
+}
+
diff --git a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml
new file mode 100644
index 0000000..871f598
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.info.yml
@@ -0,0 +1,3 @@
+type: module
+core: 8.x
+name: 'ModuleHandler test module'
diff --git a/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module
new file mode 100644
index 0000000..638a3dc
--- /dev/null
+++ b/core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test/module_handler_test.module
@@ -0,0 +1,5 @@
+<?php
+
+function module_handler_test_hook($arg) {
+  return $arg;
+}
