diff --git a/private_message.theme.inc b/private_message.theme.inc
index 0d92faa..084ecb6 100644
--- a/private_message.theme.inc
+++ b/private_message.theme.inc
@@ -12,7 +12,7 @@ use Drupal\Core\Url;
  * Implements hook_preprocess_private_message_notification_block().
  */
 function template_preprocess_private_message_notification_block(&$vars) {
-  $vars['notification_image_path'] = base_path() . drupal_get_path('module', 'private_message') . '/images/private-message-notification-icon.png';
+  $vars['notification_image_path'] = base_path() . \Drupal::service('extension.list.module')->getPath('private_message') . '/images/private-message-notification-icon.png';
   $link_title = $vars['new_message_count'] ? \Drupal::service('string_translation')->formatPlural($vars['new_message_count'], 'You have 1 unread private message', 'You have @count unread private messages') : t('You have no unread private messages');
   $url = Url::fromRoute('private_message.private_message_page', [], ['attributes' => ['title' => $link_title, 'class' => ['private-message-page-link']]]);
   $count = $vars['new_message_count'] > 99 ? '99+' : $vars['new_message_count'];
diff --git a/src/Plugin/Field/FieldFormatter/PrivateMessageThreadMemberFormatter.php b/src/Plugin/Field/FieldFormatter/PrivateMessageThreadMemberFormatter.php
index c793da3..1e827fa 100644
--- a/src/Plugin/Field/FieldFormatter/PrivateMessageThreadMemberFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/PrivateMessageThreadMemberFormatter.php
@@ -285,7 +285,7 @@ class PrivateMessageThreadMemberFormatter extends FormatterBase implements Conta
           }
           elseif ($this->getSetting('display_type') == 'entity') {
             $renderable = $view_builder->view($user, $this->getSetting('entity_display_mode'));
-            $users[$user->id()] = render($renderable);
+            $users[$user->id()] = \Drupal::service('renderer')->render($renderable);
           }
         }
       }
diff --git a/tests/src/Functional/PrivateMessageNotificationTest.php b/tests/src/Functional/PrivateMessageNotificationTest.php
index 484a6d7..b8e6943 100644
--- a/tests/src/Functional/PrivateMessageNotificationTest.php
+++ b/tests/src/Functional/PrivateMessageNotificationTest.php
@@ -39,7 +39,7 @@ class PrivateMessageNotificationTest extends BrowserTestBase {
   /**
    * SetUp the test class.
    */
-  public function setUp() {
+  public function setUp(): void {
     parent::setUp();
     $this->userA = $this->drupalCreateUser([
       'use private messaging system',
@@ -60,16 +60,16 @@ class PrivateMessageNotificationTest extends BrowserTestBase {
     $this->drupalLogin($this->userA);
 
     $this->drupalGet('/private-message/create');
-    $this->assertResponse(200);
-    $this->drupalPostForm(NULL, [
+    $this->assertSession()->statusCodeEquals(200);
+    $this->submitForm([
       'members[0][target_id]' => $this->userB->getDisplayName(),
       'message[0][value]' => $this->getRandomGenerator()->sentences(5),
     ], 'Send');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
 
     $this->drupalLogin($this->userB);
     $this->drupalGet('private-message/create');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->elementTextContains('css', 'a.private-message-page-link', 1);
   }
 
diff --git a/tests/src/Functional/PrivateMessageSettingsFormTest.php b/tests/src/Functional/PrivateMessageSettingsFormTest.php
index d852acf..54a9f41 100644
--- a/tests/src/Functional/PrivateMessageSettingsFormTest.php
+++ b/tests/src/Functional/PrivateMessageSettingsFormTest.php
@@ -39,7 +39,7 @@ class PrivateMessageSettingsFormTest extends BrowserTestBase {
   /**
    * SetUp the test class.
    */
-  public function setUp() {
+  public function setUp(): void {
     parent::setUp();
     $this->user = $this->DrupalCreateUser();
     $this->adminUser = $this->DrupalCreateUser([
@@ -54,11 +54,11 @@ class PrivateMessageSettingsFormTest extends BrowserTestBase {
   public function testSettingsPageExists() {
     $this->drupalLogin($this->user);
     $this->drupalGet('admin/config/private-message/config');
-    $this->assertResponse(403);
+    $this->assertSession()->statusCodeEquals(403);
 
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config/private-message/config');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
   }
 
   /**
@@ -67,13 +67,11 @@ class PrivateMessageSettingsFormTest extends BrowserTestBase {
   public function testConfigForm() {
     $this->drupalLogin($this->adminUser);
     $this->drupalGet('admin/config/private-message/config');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
 
     // Test form submission.
-    $this->drupalPostForm(NULL, [], t('Save configuration'));
-    $this->assertText(
-      'The configuration options have been saved.'
-    );
+    $this->submitForm([], t('Save configuration'));
+    $this->assertSession()->pageTextContains('The configuration options have been saved.');
   }
 
 }
diff --git a/tests/src/Functional/PrivateMessageThreadMembersTest.php b/tests/src/Functional/PrivateMessageThreadMembersTest.php
index 4455a20..2573ce1 100644
--- a/tests/src/Functional/PrivateMessageThreadMembersTest.php
+++ b/tests/src/Functional/PrivateMessageThreadMembersTest.php
@@ -46,7 +46,7 @@ class PrivateMessageThreadMembersTest extends BrowserTestBase {
   /**
    * {@inheritdoc}
    */
-  protected function setUp() {
+  protected function setUp(): void {
     parent::setUp();
     $this->userA = $this->drupalCreateUser([
       'use private messaging system',
diff --git a/tests/src/Functional/PrivateMessageUnreadCountTest.php b/tests/src/Functional/PrivateMessageUnreadCountTest.php
index a537e1f..b4e4d22 100644
--- a/tests/src/Functional/PrivateMessageUnreadCountTest.php
+++ b/tests/src/Functional/PrivateMessageUnreadCountTest.php
@@ -40,7 +40,7 @@ class PrivateMessageUnreadCountTest extends BrowserTestBase {
   /**
    * SetUp the test class.
    */
-  public function setUp() {
+  public function setUp(): void {
     parent::setUp();
     $this->userA = $this->drupalCreateUser([
       'use private messaging system',
@@ -61,12 +61,12 @@ class PrivateMessageUnreadCountTest extends BrowserTestBase {
     $this->drupalLogin($this->userA);
 
     $this->drupalGet('/private-message/create');
-    $this->assertResponse(200);
-    $this->drupalPostForm(NULL, [
+    $this->assertSession()->statusCodeEquals(200);
+    $this->submitForm([
       'members[0][target_id]' => $this->userB->getDisplayName(),
       'message[0][value]' => $this->getRandomGenerator()->sentences(5),
     ], 'Send');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
     // I should not see a notification for my own message.
     $this->assertSession()->elementTextContains('css', 'a.private-message-page-link', 0);
     // When going to a different page, I should still not see a notification for
@@ -80,14 +80,14 @@ class PrivateMessageUnreadCountTest extends BrowserTestBase {
 
     // We visit the thread directly.
     $this->drupalGet('private-messages/1');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->elementTextContains('css', 'a.private-message-page-link', 0);
 
     // We are not already looking at the thread.
-    $this->drupalPostForm(NULL, [
+    $this->submitForm([
       'message[0][value]' => $this->getRandomGenerator()->sentences(5),
     ], 'Send');
-    $this->assertResponse(200);
+    $this->assertSession()->statusCodeEquals(200);
     // I should not see a notification for my own message.
     $this->assertSession()->elementTextContains('css', 'a.private-message-page-link', 0);
 
