diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php
index 8a22bc5..739cb38 100644
--- a/core/lib/Drupal/Core/CoreServiceProvider.php
+++ b/core/lib/Drupal/Core/CoreServiceProvider.php
@@ -130,7 +130,7 @@ public function alter(ContainerBuilder $container) {
    */
   protected function registerTest(ContainerBuilder $container) {
     // Do nothing if we are not in a test environment.
-    if (!drupal_valid_test_ua()) {
+    if (!drupal_valid_test_ua() || !defined('DRUPAL_TEST_IN_CHILD_SITE')) {
       return;
     }
     // Add the HTTP request middleware to Guzzle.
diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
index 1605ad6..aba413a 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Component\FileCache\FileCacheFactory;
 use Drupal\Core\Database\Database;
+use GuzzleHttp\Exception\GuzzleException;
 use org\bovigo\vfs\vfsStream;
 use org\bovigo\vfs\visitor\vfsStreamStructureVisitor;
 
@@ -158,6 +159,31 @@ public function testCompiledContainerIsDestructed() {
   }
 
   /**
+   * Tests that drupal_generate_test_ua() can be called from within a test.
+   */
+  public function testGenerateTestUa() {
+    drupal_generate_test_ua($this->databasePrefix);
+  }
+
+  /**
+   * Tests that an outbound HTTP request can be performed inside of a test.
+   *
+   * This is a regression test.
+   */
+  public function testOutboundHttpRequest() {
+    // When outbound HTTP requests are performed in tests
+    // TestHttpClientMiddleware ends up calling drupal_generate_test_ua(), so
+    // acts as a regression test.
+    try {
+      $this->container->get('http_client')->get('http://example.com');
+    }
+    catch (GuzzleException $e) {
+      // The bug this test is testing caused a notice, actually completing the
+      // HTTP request should not be required.
+    }
+  }
+
+  /**
    * @covers ::render
    */
   public function testRender() {
