diff --git a/src/Tests/MasqueradeAccessTest.php b/tests/src/Functional/MasqueradeAccessTest.php
similarity index 71%
rename from src/Tests/MasqueradeAccessTest.php
rename to tests/src/Functional/MasqueradeAccessTest.php
index 739e92e..2d1aa0f 100644
--- a/src/Tests/MasqueradeAccessTest.php
+++ b/tests/src/Functional/MasqueradeAccessTest.php
@@ -1,6 +1,8 @@
 <?php
 
-namespace Drupal\masquerade\Tests;
+namespace Drupal\Tests\masquerade\Functional;
+
+use Drupal\Core\Session\AccountInterface;
 
 /**
  * Tests masquerade access mechanism.
@@ -75,48 +77,51 @@ class MasqueradeAccessTest extends MasqueradeWebTestBase {
     $edit = [
       'masquerade_as' => $this->masquerade_user->getAccountName(),
     ];
-    $this->drupalPostForm('masquerade', $edit, t('Switch'));
-    $this->assertRaw(t('You cannot masquerade as yourself. Please choose a different user to masquerade as.'));
-    $this->assertNoText(t('Unmasquerade'));
+    $this->drupalPostForm('masquerade', $edit, $this->t('Switch'));
+    $this->assertSession()
+      ->responseContains($this->t('You cannot masquerade as yourself. Please choose a different user to masquerade as.'));
+    $this->assertSession()->pageTextNotContains($this->t('Unmasquerade'));
 
     // Basic 'masquerade' permission check.
     $this->drupalLogin($this->auth_user);
     $this->drupalGet('masquerade');
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
   }
 
   /**
    * Asserts that the logged-in user can masquerade as a given target user.
    *
-   * @param \Drupal\user\UserInterface $target_account
+   * @param \Drupal\Core\Session\AccountInterface $target_account
    *   The user to masquerade to.
    */
-  protected function assertCanMasqueradeAs($target_account) {
+  protected function assertCanMasqueradeAs(AccountInterface $target_account) {
     $edit = [
       'masquerade_as' => $target_account->getAccountName(),
     ];
-    $this->drupalPostForm('masquerade', $edit, t('Switch'));
-    $this->assertNoRaw(t('You are not allowed to masquerade as %name.', [
-      '%name' => $target_account->getDisplayName(),
-    ]));
-    $this->clickLink(t('Unmasquerade'));
+    $this->drupalPostForm('masquerade', $edit, $this->t('Switch'));
+    $this->assertSession()
+      ->responseNotContains($this->t('You are not allowed to masquerade as %name.', [
+        '%name' => $target_account->getDisplayName(),
+      ]));
+    $this->clickLink($this->t('Unmasquerade'));
   }
 
   /**
    * Asserts that the logged-in user can not masquerade as a given target user.
    *
-   * @param \Drupal\user\UserInterface $target_account
+   * @param \Drupal\Core\Session\AccountInterface $target_account
    *   The user to masquerade to.
    */
-  protected function assertCanNotMasqueradeAs($target_account) {
+  protected function assertCanNotMasqueradeAs(AccountInterface $target_account) {
     $edit = [
       'masquerade_as' => $target_account->getAccountName(),
     ];
-    $this->drupalPostForm('masquerade', $edit, t('Switch'));
-    $this->assertRaw(t('You are not allowed to masquerade as %name.', [
-      '%name' => $target_account->getDisplayName(),
-    ]));
-    $this->assertNoText(t('Unmasquerade'));
+    $this->drupalPostForm('masquerade', $edit, $this->t('Switch'));
+    $this->assertSession()
+      ->responseContains($this->t('You are not allowed to masquerade as %name.', [
+        '%name' => $target_account->getDisplayName(),
+      ]));
+    $this->assertSession()->pageTextNotContains($this->t('Unmasquerade'));
   }
 
 }
diff --git a/src/Tests/MasqueradeCacheTest.php b/tests/src/Functional/MasqueradeCacheTest.php
similarity index 92%
rename from src/Tests/MasqueradeCacheTest.php
rename to tests/src/Functional/MasqueradeCacheTest.php
index 6d6d7c8..3ed7fcd 100644
--- a/src/Tests/MasqueradeCacheTest.php
+++ b/tests/src/Functional/MasqueradeCacheTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\masquerade\Tests;
+namespace Drupal\Tests\masquerade\Functional;
 
 /**
  * Tests caching for masquerade.
@@ -46,7 +46,7 @@ class MasqueradeCacheTest extends MasqueradeWebTestBase {
 
     // Masquerade as Nelle.
     $edit = ['masquerade_as' => $nelle->getAccountName()];
-    $this->drupalPostForm(NULL, $edit, t('Switch'));
+    $this->drupalPostForm(NULL, $edit, $this->t('Switch'));
     $this->drupalGet('<front>');
     $this->assertNoBlockAppears($masquerade_block);
 
diff --git a/src/Tests/MasqueradeTest.php b/tests/src/Functional/MasqueradeTest.php
similarity index 83%
rename from src/Tests/MasqueradeTest.php
rename to tests/src/Functional/MasqueradeTest.php
index af29618..fcf8b82 100644
--- a/src/Tests/MasqueradeTest.php
+++ b/tests/src/Functional/MasqueradeTest.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Drupal\masquerade\Tests;
+namespace Drupal\Tests\masquerade\Functional;
 
 /**
  * Tests form permissions and user switching functionality.
@@ -17,9 +17,9 @@ class MasqueradeTest extends MasqueradeWebTestBase {
 
     // Verify that a token is required.
     $this->drupalGet('user/0/masquerade');
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
     $this->drupalGet('user/' . $this->auth_user->id() . '/masquerade');
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
 
     // Verify that the admin user is able to masquerade.
     $this->assertSessionByUid($this->admin_user->id(), FALSE);
@@ -29,7 +29,7 @@ class MasqueradeTest extends MasqueradeWebTestBase {
 
     // Verify that a token is required to unmasquerade.
     $this->drupalGet('unmasquerade');
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
 
     // Verify that the web user cannot masquerade.
     $this->drupalGet('user/' . $this->admin_user->id() . '/masquerade', [
@@ -37,7 +37,7 @@ class MasqueradeTest extends MasqueradeWebTestBase {
         'token' => $this->drupalGetToken('user/' . $this->admin_user->id() . '/masquerade'),
       ],
     ]);
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
 
     // Verify that the user can unmasquerade.
     $this->unmasquerade($this->auth_user);
@@ -46,4 +46,3 @@ class MasqueradeTest extends MasqueradeWebTestBase {
   }
 
 }
-
diff --git a/src/Tests/MasqueradeWebTestBase.php b/tests/src/Functional/MasqueradeWebTestBase.php
similarity index 79%
rename from src/Tests/MasqueradeWebTestBase.php
rename to tests/src/Functional/MasqueradeWebTestBase.php
index 7f55415..4688fb3 100644
--- a/src/Tests/MasqueradeWebTestBase.php
+++ b/tests/src/Functional/MasqueradeWebTestBase.php
@@ -1,10 +1,12 @@
 <?php
 
-namespace Drupal\masquerade\Tests;
+namespace Drupal\Tests\masquerade\Functional;
 
 use Drupal\Component\Utility\Crypt;
 use Drupal\Core\Site\Settings;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\block\Functional\AssertBlockAppearsTrait;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Drupal\Tests\BrowserTestBase;
 use Drupal\user\Entity\Role;
 use Drupal\user\UserInterface;
 
@@ -15,7 +17,10 @@ use Drupal\user\UserInterface;
  *   request.
  * @see http://drupal.org/node/1555862
  */
-abstract class MasqueradeWebTestBase extends WebTestBase {
+abstract class MasqueradeWebTestBase extends BrowserTestBase {
+
+  use AssertBlockAppearsTrait;
+  use StringTranslationTrait;
 
   /**
    * Modules to install.
@@ -122,15 +127,16 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
    */
   protected function masqueradeAs(UserInterface $account) {
     $this->drupalGet('user/' . $account->id());
-    $this->clickLink(t('Masquerade as @name', ['@name' => $account->getDisplayName()]));
-    // @todo Fix when crsfTokenSeed is avalable.
-//    $this->drupalGet('user/' . $account->id() . '/masquerade', array(
-//      'query' => array(
-//        'token' => $this->drupalGetToken('user/' . $account->id() . '/masquerade'),
-//      ),
-//    ));
-    $this->assertResponse(200);
-    $this->assertText('You are now masquerading as ' . $account->label());
+    $this->clickLink($this->t('Masquerade as @name', ['@name' => $account->getDisplayName()]));
+    // @todo Fix when crsfTokenSeed is available.
+    //    $this->drupalGet('user/' . $account->id() . '/masquerade', array(
+    //      'query' => array(
+    //        'token' => $this->drupalGetToken('user/' . $account->id() . '/masquerade'),
+    //      ),
+    //    ));
+    $this->assertSession()->statusCodeEquals(200);
+    $this->assertSession()
+      ->pageTextContains('You are now masquerading as ' . $account->label());
 
     // Update the logged in user account.
     // @see WebTestBase::drupalLogin()
@@ -147,16 +153,17 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
    *   The user account to unmasquerade from.
    */
   protected function unmasquerade(UserInterface $account) {
-    $this->drupalGet('/user/' . $account->id());
+    $this->drupalGet('user/' . $account->id());
     $this->clickLink('Unmasquerade');
     // @todo Fix when crsfTokenSeed is avalable.
-//    $this->drupalGet('unmasquerade', array(
-//      'query' => array(
-//        'token' => $this->drupalGetToken('unmasquerade'),
-//      ),
-//    ));
-    $this->assertResponse(200);
-    $this->assertText('You are no longer masquerading as ' . $account->label());
+    //    $this->drupalGet('unmasquerade', array(
+    //      'query' => array(
+    //        'token' => $this->drupalGetToken('unmasquerade'),
+    //      ),
+    //    ));
+    $this->assertSession()->statusCodeEquals(200);
+    $this->assertSession()
+      ->pageTextContains('You are no longer masquerading as ' . $account->label());
 
     // Update the logged in user account.
     // @see WebTestBase::drupalLogin()
@@ -179,18 +186,18 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
    *   The session record from {sessions}, if any.
    */
   protected function assertSessionByUid($uid, $expected_masquerading_uid = NULL) {
-    $result = db_query('SELECT * FROM {sessions} WHERE uid = :uid', array(
+    $result = db_query('SELECT * FROM {sessions} WHERE uid = :uid', [
       ':uid' => $uid,
-    ))->fetchAll();
+    ])->fetchAll();
     if (empty($result)) {
-      $this->fail(format_string('No session found for uid @uid', array('@uid' => $uid)));
+      $this->fail(format_string('No session found for uid @uid', ['@uid' => $uid]));
     }
     elseif (count($result) > 1) {
       // If there is more than one session, then that must be unexpected.
       $this->fail("Found more than 1 session for uid $uid.");
     }
     else {
-      $this->pass("Found session for uid $uid.");
+      $this->assertTrue(TRUE, "Found session for uid $uid.");
       $session = reset($result);
 
       // Decode the session data.
@@ -206,12 +213,12 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
         // @see drupal_session_start()
         @session_start();
         // In any case, ensure that it is empty.
-        $_SESSION = array();
+        $_SESSION = [];
 
         if (!session_decode($session->session)) {
-          $this->fail(format_string('Failed to decode session data: @data', array('@data' => $session->session)));
+          $this->fail(format_string('Failed to decode session data: @data', ['@data' => $session->session]));
         }
-        $session->session = isset($_SESSION) ? $_SESSION : array();
+        $session->session = isset($_SESSION) ? $_SESSION : [];
 
         // Restore the original global session.
         $_SESSION = NULL;
@@ -221,17 +228,17 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
       }
       else {
         $session = new \stdClass();
-        $session->session = array();
+        $session->session = [];
       }
 
       if (isset($expected_masquerading_uid)) {
         if ($expected_masquerading_uid !== FALSE) {
-          $this->assertEqual($session->session['masquerading'], $expected_masquerading_uid, format_string('$_SESSION[\'masquerading\'] equals @uid.', array(
+          $this->assertEquals($expected_masquerading_uid, $session->session['masquerading'], format_string('$_SESSION[\'masquerading\'] equals @uid.', [
             '@uid' => $expected_masquerading_uid,
-          )));
+          ]));
         }
         else {
-          $this->assert(!isset($session->session['masquerading']), '$_SESSION[\'masquerading\'] is not set.');
+          self::assertArrayNotHasKey('masquerading', $session->session, '$_SESSION[\'masquerading\'] is not set.');
         }
       }
       return $session;
@@ -245,10 +252,10 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
    *   The user ID to assert.
    */
   protected function assertNoSessionByUid($uid) {
-    $result = db_query('SELECT * FROM {sessions} WHERE uid = :uid', array(
+    $result = db_query('SELECT * FROM {sessions} WHERE uid = :uid', [
       ':uid' => $uid,
-    ))->fetchAll();
-    $this->assert(empty($result), "No session for uid $uid found.");
+    ])->fetchAll();
+    self::assertEmpty($result, "No session for uid $uid found.");
   }
 
   /**
@@ -267,4 +274,3 @@ abstract class MasqueradeWebTestBase extends WebTestBase {
   }
 
 }
-
