diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 6abe08a..e7650e4 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2311,18 +2311,19 @@ function drupal_get_bootstrap_phase() {
  * $language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
  * @endcode
  *
- * @param $reset
- *   TRUE or FALSE depending on whether the Container instance is to be reset.
+ * @param bool $reset
+ *   (optional) TRUE to reset the container instance. Defaults to FALSE.
  *
  * @return Symfony\Component\DependencyInjection\ContainerBuilder
  *   The instance of the Drupal Container used to set up and maintain object
- *   instances.
+ *   instances. Returned by reference.
  */
-function drupal_container($reset = FALSE) {
+function &drupal_container($reset = FALSE) {
   // We do not use drupal_static() here because we do not have a mechanism by
   // which to reinitialize the stored objects, so a drupal_static_reset() call
   // would leave Drupal in a nonfunctional state.
   static $container = NULL;
+
   if ($reset || !isset($container)) {
     $container = new ContainerBuilder();
     // An interface language always needs to be available for t() and other
diff --git a/core/modules/path/path.test b/core/modules/path/path.test
index a3f5820..0066071 100644
--- a/core/modules/path/path.test
+++ b/core/modules/path/path.test
@@ -542,6 +542,9 @@ class PathMonolingualTestCase extends PathTestCase {
     // Set language detection to URL.
     $edit = array('language_interface[enabled][language-url]' => TRUE);
     $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
+
+    // Force languages to be initialized.
+    drupal_language_initialize();
   }
 
   /**
diff --git a/core/modules/simpletest/drupal_web_test_case.php b/core/modules/simpletest/drupal_web_test_case.php
index 540dc0e..46ffdc5 100644
--- a/core/modules/simpletest/drupal_web_test_case.php
+++ b/core/modules/simpletest/drupal_web_test_case.php
@@ -1312,6 +1312,7 @@ class DrupalWebTestCase extends DrupalTestCase {
     Database::addConnectionInfo('default', 'default', $connection_info['default']);
 
     // Store necessary current values before switching to prefixed database.
+    $this->originalContainer = clone drupal_container();
     $this->originalLanguage = $language_interface;
     $this->originalLanguageDefault = variable_get('language_default');
     $this->originalConfigDirectory = $GLOBALS['config_directory_name'];
@@ -1559,6 +1560,10 @@ class DrupalWebTestCase extends DrupalTestCase {
     Database::removeConnection('default');
     Database::renameConnection('simpletest_original_default', 'default');
 
+    // Restore dependency injection container.
+    $container = &drupal_container();
+    $container = $this->originalContainer;
+
     // Restore original shutdown callbacks array to prevent original
     // environment of calling handlers from test run.
     $callbacks = &drupal_register_shutdown_function();
