diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index d48c6f2..0bb8bd3 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -489,6 +489,15 @@ public static function convertDbUrlToConnectionInfo($url, $root) {
     if (isset($info['port'])) {
       $database['port'] = $info['port'];
     }
+
+    if (isset($info['query'])) {
+      $parts = array();
+      parse_str($info['query'], $parts);
+      if (isset($parts['namespace'])) {
+        $database['namespace'] = $parts['namespace'];
+      }
+    }
+
     return $database;
   }
 
@@ -525,6 +534,9 @@ public static function getConnectionInfoAsUrl($key = 'default') {
     if ($db_info['default']['prefix']['default']) {
       $db_url .= '#' . $db_info['default']['prefix']['default'];
     }
+    if (isset($db_info['default']['namespace'])) {
+      $db_url .= '?namespace=' . $db_info['default']['namespace'];
+    }
     return $db_url;
   }
 
diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index b994352..a831808 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -180,11 +180,16 @@ function simpletest_run_phpunit_tests($test_id, array $unescaped_test_classnames
   $ret = simpletest_phpunit_run_command($unescaped_test_classnames, $phpunit_file);
   // A return value of 0 = passed test, 1 = failed test, > 1 indicates segfault
   // timeout, or other type of failure.
-  if ($ret > 1) {
+  // But > 1 does not necessarily mean that we cannot get some extra
+  // details for the output.
+  try {
+    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file);
+  }
+  catch (\Exception $e) {
     // Something broke during the execution of phpunit.
     // Return an error record of all failed classes.
     $rows[] = [
-      'test_id' => '1',
+      'test_id' => $test_id,
       'test_class' => implode(",", $unescaped_test_classnames),
       'status' => 'fail',
       'message' => 'PHPunit Test failed to complete',
@@ -194,9 +199,6 @@ function simpletest_run_phpunit_tests($test_id, array $unescaped_test_classnames
       'file' => $phpunit_file,
     ];
   }
-  else {
-    $rows = simpletest_phpunit_xml_to_rows($test_id, $phpunit_file);
-  }
   return $rows;
 }
 
@@ -316,7 +318,7 @@ function simpletest_phpunit_command() {
   if (substr(PHP_OS, 0, 3) == 'WIN') {
     $php_executable_finder = new PhpExecutableFinder();
     $php = $php_executable_finder->find();
-    $phpunit_bin = escapeshellarg($php) . ' -f ' . escapeshellarg($vendor_dir . '/phpunit/phpunit/composer/bin/phpunit') . ' --';
+    $phpunit_bin = escapeshellarg($php) . ' -f ' . escapeshellarg($vendor_dir . '/phpunit/phpunit/phpunit') . ' --';
   }
   else {
     $phpunit_bin = $vendor_dir . '/phpunit/phpunit/phpunit';
