diff --git a/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php b/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
index f86b85e..d81b06c 100644
--- a/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Unit/WebTestBaseTest.php
@@ -218,6 +218,7 @@ public function testGetAbsoluteUrl($href, $expected_absolute_path) {
     $get_absolute_url_method->setAccessible(TRUE);
 
     $this->assertSame($expected_absolute_path, $get_absolute_url_method->invoke($web_test, $href));
+    unset($GLOBALS['base_url'], $GLOBALS['base_path']);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
index 7cd66f2..f574106 100644
--- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
+++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php
@@ -68,15 +68,12 @@ protected function findPhpClasses($dir) {
    */
   protected function assertNoCoreUsage($class_path) {
     $contents = file_get_contents($class_path);
-    if (preg_match_all('/^.*Drupal\\\Core.*$/m', $contents, $matches)) {
-      foreach ($matches[0] as $line) {
-        if ((strpos($line, '@see ') === FALSE)) {
-          $this->fail(
-            "Illegal reference to 'Drupal\\Core' namespace in $class_path"
-          );
-        }
-      }
-    }
+    preg_match_all('/^.*Drupal\\\Core.*$/m', $contents, $matches);
+    $matches = array_filter($matches[0], function($line) {
+      // Filter references to @see as they don't really matter.
+      return strpos($line, '@see') === FALSE;
+    });
+    $this->assertEmpty($matches, "Checking for illegal reference to 'Drupal\\Core' namespace in $class_path");
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
index 8cf9642..e5e1082 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php
@@ -75,6 +75,7 @@ public function testReadOnly() {
     // Saving and deleting should always fail.
     $this->assertFalse($php_read->save($name, $code));
     $this->assertFalse($php_read->delete($name));
+    unset($GLOBALS[$random]);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
index e0a7d81..456e6f0 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
@@ -86,6 +86,7 @@ public function testDeleteAll() {
 
     // Should still return TRUE if directory has already been deleted.
     $this->assertTrue($php->deleteAll(), 'Delete all succeeds with nothing to delete');
+    unset($GLOBALS[$random]);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
index 5667e42..59944ff 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php
@@ -124,6 +124,7 @@ public function testSecurity() {
       $this->assertSame($php->load($name), $this->expected[$i]);
       $this->assertSame($GLOBALS['hacked'], $this->expected[$i]);
     }
+    unset($GLOBALS['hacked']);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
index 53492d8..9abc86b 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/PhpStorageTestBase.php
@@ -60,6 +60,7 @@ public function assertCRUD($php) {
     // Ensure delete() can be called on a non-existing file. It should return
     // FALSE, but not trigger errors.
     $this->assertFalse($php->delete($name), 'Delete fails on missing file');
+    unset($GLOBALS[$random]);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/core/tests/Drupal/Tests/ComposerIntegrationTest.php
index fdaef71..ae538fb 100644
--- a/core/tests/Drupal/Tests/ComposerIntegrationTest.php
+++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php
@@ -22,6 +22,7 @@ class ComposerIntegrationTest extends UnitTestCase {
    */
   protected function getErrorMessages() {
     $messages = [
+      0 => 'No errors found',
       JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded',
       JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
       JSON_ERROR_CTRL_CHAR => 'Control character error, possibly incorrectly encoded',
@@ -62,9 +63,7 @@ public function testComposerJson() {
       $json = file_get_contents($path . '/composer.json');
 
       $result = json_decode($json);
-      if (is_null($result)) {
-        $this->fail($this->getErrorMessages()[json_last_error()]);
-      }
+      $this->assertNotNull($result, $this->getErrorMessages()[json_last_error()]);
     }
   }
 
diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
index 4b94055..030fb4d 100644
--- a/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
+++ b/core/tests/Drupal/Tests/Core/EventSubscriber/SpecialAttributesRouteSubscriberTest.php
@@ -84,6 +84,7 @@ public function testOnRouteBuildingValidVariables(Route $route) {
     $route_collection->add('test', $route);
     $event = new RouteBuildEvent($route_collection, 'test');
     $this->specialAttributesRouteSubscriber->onAlterRoutes($event);
+    $this->assertTrue(TRUE, 'No errors where thrown');
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
index d659849..b9bb4e5 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php
@@ -302,7 +302,7 @@ public function providerTestContextBubblingEdgeCases() {
    * Tests the self-healing of the redirect with conditional cache contexts.
    */
   public function testConditionalCacheContextBubblingSelfHealing() {
-    global $current_user_role;
+    $current_user_role = &$this->currentUserRole;
 
     $this->setUpRequest();
     $this->setupMemoryCache();
@@ -319,8 +319,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
           'tags' => ['b'],
         ],
         'grandchild' => [
-          '#access_callback' => function () {
-            global $current_user_role;
+          '#access_callback' => function() use (&$current_user_role) {
             // Only role A cannot access this subtree.
             return $current_user_role !== 'A';
           },
@@ -331,8 +330,7 @@ public function testConditionalCacheContextBubblingSelfHealing() {
             'max-age' => 1800,
           ],
           'grandgrandchild' => [
-            '#access_callback' => function () {
-                global $current_user_role;
+            '#access_callback' => function () use (&$current_user_role) {
                 // Only role C can access this subtree.
                 return $current_user_role === 'C';
               },
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
index 9e3aaa7..2f8dd66 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@@ -434,7 +434,8 @@ public function testScalarLazybuilderCallbackContext() {
       'null' => NULL,
     ]];
 
-    $this->renderer->renderRoot($element);
+    $result = $this->renderer->renderRoot($element);
+    $this->assertEquals('<p>This is a rendered placeholder!</p>', (string) $result);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
index 9ab8978..eb4dff4 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
@@ -80,6 +80,11 @@ class RendererTestBase extends UnitTestCase {
   protected $memoryCache;
 
   /**
+   * @var string
+   */
+  protected $currentUserRole;
+
+  /**
    * The mocked renderer configuration.
    *
    * @var array
@@ -108,10 +113,10 @@ protected function setUp() {
     $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
       ->disableOriginalConstructor()
       ->getMock();
+    $current_user_role = &$this->currentUserRole;
     $this->cacheContextsManager->expects($this->any())
       ->method('convertTokensToKeys')
-      ->willReturnCallback(function($context_tokens) {
-        global $current_user_role;
+      ->willReturnCallback(function($context_tokens) use (&$current_user_role) {
         $keys = [];
         foreach ($context_tokens as $context_id) {
           switch ($context_id) {
@@ -140,6 +145,10 @@ protected function setUp() {
     \Drupal::setContainer($container);
   }
 
+  public function tearDown() {
+    unset($this->currentUserRole);
+  }
+
   /**
    * Generates a random context value for the placeholder tests.
    *
