diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index ac20992..dd1eefc 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -1746,6 +1746,7 @@ function drupal_generate_test_ua($prefix) {
   if (!isset($key) || $last_prefix != $prefix) {
     $last_prefix = $prefix;
     $key_file = DRUPAL_ROOT . '/sites/simpletest/' . substr($prefix, 10) . '/.htkey';
+    $generate_key = TRUE;
     // When issuing an outbound HTTP client request from within an inbound test
     // request, then the outbound request has to use the same User-Agent header
     // as the inbound request. A newly generated private key for the same test
@@ -1755,10 +1756,15 @@ function drupal_generate_test_ua($prefix) {
       if ($parent_prefix != $prefix) {
         throw new \RuntimeException("Malformed User-Agent: Expected '$parent_prefix' but got '$prefix'.");
       }
-      // If the file is not readable, a PHP warning is expected in this case.
-      $private_key = file_get_contents($key_file);
+      if (file_exists($key_file)) {
+        // If the file is not readable, a PHP warning is expected in this case.
+        $private_key = file_get_contents($key_file);
+        // If the file does not exist then do not generate one.
+        $generate_key = FALSE;
+      }
     }
-    else {
+
+    if ($generate_key) {
       // Generate and save a new hash salt for a test run.
       // Consumed by drupal_valid_test_ua() before settings.php is loaded.
       $private_key = Crypt::randomBytesBase64(55);
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
old mode 100755
new mode 100644
index e46051d..fecd002
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/SimpleTestTest.php
@@ -181,6 +181,26 @@ function testWebTestRunner() {
   }
 
   /**
+   * Tests that WebTestBase and KernalTestBase tests work through the UI.
+   */
+  function testTestingThroughUI() {
+    $this->drupalGet('admin/config/development/testing');
+    $edit = array(
+      // A WebTestBase test.
+      'tests[Drupal\config\Tests\ConfigImportUITest]' => TRUE,
+    );
+    $this->drupalPostForm(NULL, $edit, t('Run tests'));
+    $this->assertText('0 fails, 0 exceptions');
+    $this->drupalGet('admin/config/development/testing');
+    $edit = array(
+      // A KernalTestBase test.
+      'tests[Drupal\text\Tests\Formatter\TextPlainUnitTest]' => TRUE,
+    );
+    $this->drupalPostForm(NULL, $edit, t('Run tests'));
+    $this->assertText('0 fails, 0 exceptions');
+  }
+
+  /**
    * Test to be run and the results confirmed.
    */
   function stubTest() {
