diff --git a/reroute_email.info.yml b/reroute_email.info.yml
index 145f405..2e1d4a9 100644
--- a/reroute_email.info.yml
+++ b/reroute_email.info.yml
@@ -2,5 +2,6 @@ name: 'Reroute emails'
 description: 'Reroutes emails send from the site to a predefined email. Useful for test sites.'
 package: Development
 core: 8.x
+core_version_requirement: ^8 || ^9
 configure: reroute_email.settings
 type: module
diff --git a/reroute_email.module b/reroute_email.module
index dba6121..910222f 100644
--- a/reroute_email.module
+++ b/reroute_email.module
@@ -8,7 +8,6 @@
 use Drupal\Core\StringTranslation\TranslatableMarkup;
 use Egulias\EmailValidator\EmailParser;
 use Egulias\EmailValidator\EmailLexer;
-use Drupal\Component\Utility\Unicode;
 
 define('REROUTE_EMAIL_ENABLE', 'enable');
 define('REROUTE_EMAIL_ADDRESS', 'address');
@@ -231,7 +230,7 @@ function reroute_email_check(array &$message) {
       // The part after the @ sign is the domain and according to RFC 1035,
       // section 3.1: "Name servers and resolvers must compare [domains] in a
       // case-insensitive manner".
-      $domain = Unicode::strtolower($matches[1]);
+      $domain = mb_strtolower($matches[1]);
 
       $whitelisted_domains[$domain] = $domain;
       unset($whitelisted_addresses[$key]);
@@ -249,7 +248,7 @@ function reroute_email_check(array &$message) {
     }
 
     // Check whitelisted emails and domains.
-    $domain = Unicode::strtolower((new EmailParser(new EmailLexer()))->parse($email)['domain']);
+    $domain = mb_strtolower((new EmailParser(new EmailLexer()))->parse($email)['domain']);
     if (in_array($email, $whitelisted_addresses, TRUE) ||
       in_array($domain, $whitelisted_domains, TRUE)) {
       continue;
diff --git a/tests/src/Functional/ContactTest.php b/tests/src/Functional/ContactTest.php
index ec36629..5cbe730 100644
--- a/tests/src/Functional/ContactTest.php
+++ b/tests/src/Functional/ContactTest.php
@@ -38,7 +38,7 @@ class ContactTest extends RerouteEmailTestBase {
       'message' => $this->confirmationMessage,
       'selected' => TRUE,
     ], 'Save');
-    $this->assertResponse(200, 'Contact form named "feedback" added.');
+    $this->assertSession()->statusCodeEquals(200, 'Contact form named "feedback" added.');
 
     // Make sure that the flood controls don't break the test.
     \Drupal::service('config.factory')->getEditable('contact.settings')
@@ -66,8 +66,8 @@ class ContactTest extends RerouteEmailTestBase {
     // Go to the contact page and send an email.
     $post = ['subject[0][value]' => 'Test test test', 'message[0][value]' => 'This is a test'];
     $this->drupalPostForm('contact', $post, 'Send message');
-    $this->assertResponse(200, 'Posted contact form successfully.');
-    $this->assertText($this->confirmationMessage);
+    $this->assertSession()->statusCodeEquals(200, 'Posted contact form successfully.');
+    $this->assertSession()->pageTextContains($this->confirmationMessage);
 
     // Check rerouted email.
     $this->assertMail('to', $this->rerouteDestination, new FormattableMarkup('Email was rerouted to @address.', ['@address' => $this->rerouteDestination]));
@@ -84,7 +84,7 @@ class ContactTest extends RerouteEmailTestBase {
     // Go to the contact page and send an email.
     $post = ['subject[0][value]' => 'Test test test', 'message[0][value]' => 'This is a test'];
     $this->drupalPostForm('contact', $post, t('Send message'));
-    $this->assertText($this->confirmationMessage);
+    $this->assertSession()->pageTextContains($this->confirmationMessage);
     $this->assertMail('to', $additional_destination, 'Email was not rerouted because destination was in whitelist.');
 
     // Now change the configuration to disable reroute and set the default
@@ -97,7 +97,7 @@ class ContactTest extends RerouteEmailTestBase {
     // Go to the contact page and send an email.
     $post = ['subject[0][value]' => 'Test test test', 'message[0][value]' => 'This is a test'];
     $this->drupalPostForm('contact', $post, t('Send message'));
-    $this->assertText($this->confirmationMessage);
+    $this->assertSession()->pageTextContains($this->confirmationMessage);
 
     // Mail should not be rerouted - should go to $original_destination.
     $this->assertMail('to', $this->originalDestination, 'Mail not rerouted - sent to original destination.');
@@ -108,14 +108,14 @@ class ContactTest extends RerouteEmailTestBase {
     // Go to the contact page and send an email.
     $post = ['subject[0][value]' => 'Test test test', 'message[0][value]' => 'This is a test'];
     $this->drupalPostForm('contact', $post, t('Send message'));
-    $this->assertText($this->confirmationMessage);
+    $this->assertSession()->pageTextContains($this->confirmationMessage);
     $mails = $this->getMails();
     $mail = end($mails);
 
     // There should be nothing in the body except the contact message - no
     // body injection like 'Originally to'.
     $this->assertTrue(strpos($mail['body'], 'Originally to') === FALSE, 'Body does not contain "Originally to".');
-    $this->assertEqual($mail['headers']['X-Rerouted-Original-To'], $this->originalDestination, 'X-Rerouted-Original-To is correctly set to the original destination email.');
+    $this->assertEquals($mail['headers']['X-Rerouted-Original-To'], $this->originalDestination, 'X-Rerouted-Original-To is correctly set to the original destination email.');
   }
 
 }
diff --git a/tests/src/Functional/DefaultAddressesTest.php b/tests/src/Functional/DefaultAddressesTest.php
index 8dc222a..79e3e1f 100644
--- a/tests/src/Functional/DefaultAddressesTest.php
+++ b/tests/src/Functional/DefaultAddressesTest.php
@@ -48,19 +48,19 @@ class DefaultAddressesTest extends RerouteEmailTestBase {
 
     // Load the Reroute Email Settings form page. Ensure rerouting is enabled.
     $this->drupalGet('admin/config/development/reroute_email');
-    $this->assertFieldChecked('edit-enable', 'Email rerouting was programmatically successfully enabled.');
+    $this->assertSession()->checkboxChecked('edit-enable');
     $this->assertTrue($this->rerouteConfig->get(REROUTE_EMAIL_ENABLE), 'Rerouting is enabled.');
 
     // Email addresses field default value is system.site.mail.
-    $this->assertFieldByName(REROUTE_EMAIL_ADDRESS, $site_mail, new FormattableMarkup('reroute_email_address default value on form is system.site.mail value: @site_mail.', ['@site_mail' => $site_mail]));
+    $this->assertSession()->fieldValueEquals(REROUTE_EMAIL_ADDRESS, $site_mail);
 
     // Ensure reroute_email_address is actually empty at this point.
     $this->assertNull($this->rerouteConfig->get(REROUTE_EMAIL_ADDRESS), 'Reroute email destination address is not configured.');
 
     // Submit a test email, check if it is rerouted to system.site.mail address.
     $this->drupalPostForm('admin/config/development/reroute_email/test', ['to' => 'to@example.com'], 'Send email');
-    $this->assertText(t('Test email submitted for delivery from test form.'));
-    $this->assert(count($this->getMails()) === 1, 'Exactly one email captured.');
+    $this->assertSession()->pageTextContains(t('Test email submitted for delivery from test form.'));
+    $this->assertTrue(count($this->getMails()) === 1, 'Exactly one email captured.');
     $this->verboseEmail();
 
     // Check rerouted email is the site email address.
@@ -89,8 +89,7 @@ class DefaultAddressesTest extends RerouteEmailTestBase {
     $this->assertTrue(count($mails) == 0, 'Email sending was properly aborted because rerouting email address is an empty string.');
 
     // Check status message is displayed properly after email form submission.
-    $this->assertPattern(t('/@message_id.*was aborted by reroute email/', ['@message_id' => $mail['id']]),
-      new FormattableMarkup('Status message displayed as expected to the user with the mail ID <em>(@message_id)</em> and a link to recent log entries.', ['@message_id' => $mail['id']]));
+    $this->assertSession()->responseMatches(t('/@message_id.*was aborted by reroute email/', ['@message_id' => $mail['id']]));
 
     // Check the watchdog entry logged with aborted email message.
     $this->drupalGet('admin/reports/dblog');
@@ -104,8 +103,7 @@ class DefaultAddressesTest extends RerouteEmailTestBase {
     $this->clickLink($link_label);
 
     // Ensure the correct email is logged with default 'to' placeholder.
-    $this->assertPattern(t('/Aborted email sending for.*@message_id.*Detailed email data/', ['@message_id' => $mail['id']]),
-      new FormattableMarkup('The dblog entry recorded by Reroute Email contains a dump of the aborted email message <em>@message_id</em> and is formatted as expected.', ['@message_id' => $mail['id']]));
+    $this->assertSession()->responseMatches(t('/Aborted email sending for.*@message_id.*Detailed email data/', ['@message_id' => $mail['id']]));
   }
 
 }
diff --git a/tests/src/Functional/DomainWhitelistedTest.php b/tests/src/Functional/DomainWhitelistedTest.php
index 03f8d2b..0ec1ff5 100644
--- a/tests/src/Functional/DomainWhitelistedTest.php
+++ b/tests/src/Functional/DomainWhitelistedTest.php
@@ -21,8 +21,8 @@ class DomainWhitelistedTest extends RerouteEmailTestBase {
     $this->configureRerouteEmail(TRUE, $this->rerouteDestination, $this->whitelistedDomain);
 
     // Make sure configured emails were set.
-    $this->assertEqual($this->rerouteConfig->get(REROUTE_EMAIL_ADDRESS), $this->rerouteDestination, 'Reroute email address was set.');
-    $this->assertEqual($this->rerouteConfig->get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');
+    $this->assertEquals($this->rerouteConfig->get(REROUTE_EMAIL_ADDRESS), $this->rerouteDestination, 'Reroute email address was set.');
+    $this->assertEquals($this->rerouteConfig->get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');
 
     // Submit a test email (should be rerouted).
     $to = 'some@not-exist.domain';
diff --git a/tests/src/Functional/MultipleRecipientsTest.php b/tests/src/Functional/MultipleRecipientsTest.php
index 8d06e7f..83d6bf5 100644
--- a/tests/src/Functional/MultipleRecipientsTest.php
+++ b/tests/src/Functional/MultipleRecipientsTest.php
@@ -23,8 +23,8 @@ class MultipleRecipientsTest extends RerouteEmailTestBase {
 
     // Make sure configured emails were set properly.
     $reroute_to = 'user1@example.com,user2@example.com,user@example.com';
-    $this->assertEqual($this->rerouteConfig->get(REROUTE_EMAIL_ADDRESS), $reroute_to, 'Reroute email address was set.');
-    $this->assertEqual($this->rerouteConfig->get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');
+    $this->assertEquals($this->rerouteConfig->get(REROUTE_EMAIL_ADDRESS), $reroute_to, 'Reroute email address was set.');
+    $this->assertEquals($this->rerouteConfig->get(REROUTE_EMAIL_WHITELIST), $this->whitelistedDomain, 'Whitelisted value was set.');
 
     // Submit a test email (should be rerouted).
     $to = 'some@not-exist.domain, whitelisted@example.com';
diff --git a/tests/src/Functional/RerouteEmailTestBase.php b/tests/src/Functional/RerouteEmailTestBase.php
index 620ef36..2a3d951 100644
--- a/tests/src/Functional/RerouteEmailTestBase.php
+++ b/tests/src/Functional/RerouteEmailTestBase.php
@@ -128,7 +128,7 @@ abstract class RerouteEmailTestBase extends BrowserTestBase {
 
     // Submit Reroute Email Settings form and check if it was successful.
     $this->drupalPostForm('admin/config/development/reroute_email', $post, t('Save configuration'));
-    $this->assertText(t('The configuration options have been saved.'));
+    $this->assertSession()->pageTextContains(t('The configuration options have been saved.'));
 
     // Rebuild config values after form submit.
     $this->rerouteConfig = $this->config('reroute_email.settings');
@@ -145,7 +145,7 @@ abstract class RerouteEmailTestBase extends BrowserTestBase {
     // Check most recent email.
     $mails = $this->getMails();
     if (empty($mails)) {
-      $this->assert(FALSE, 'Email was not sent.');
+      $this->assertTrue(FALSE, 'Email was not sent.');
       return;
     }
 
diff --git a/tests/src/Functional/TestEmailFormTest.php b/tests/src/Functional/TestEmailFormTest.php
index e352e5f..6bbb01c 100644
--- a/tests/src/Functional/TestEmailFormTest.php
+++ b/tests/src/Functional/TestEmailFormTest.php
@@ -27,7 +27,7 @@ class TestEmailFormTest extends RerouteEmailTestBase {
 
     // Check Subject field default value.
     $this->drupalGet('admin/config/development/reroute_email/test');
-    $this->assertFieldByName('subject', t('Reroute Email Test'), 'The expected default value was found for the Subject field.');
+    $this->assertSession()->fieldValueEquals('subject', t('Reroute Email Test'));
 
     // Submit the Test Email form to send an email to be rerouted.
     $post = [
@@ -38,7 +38,7 @@ class TestEmailFormTest extends RerouteEmailTestBase {
       'body' => 'Testing email rerouting and the Test Email form',
     ];
     $this->drupalPostForm('admin/config/development/reroute_email/test', $post, t('Send email'));
-    $this->assertText(t('Test email submitted for delivery from test form.'));
+    $this->assertSession()->pageTextContains(t('Test email submitted for delivery from test form.'));
     $mails = $this->getMails();
     $mail = end($mails);
 
@@ -73,7 +73,7 @@ class TestEmailFormTest extends RerouteEmailTestBase {
     $this->drupalPostForm('admin/config/development/reroute_email/test', $post, t('Send email'));
 
     // Successful submission with email rerouting enabled.
-    $this->assertText(t('Test email submitted for delivery from test form.'));
+    $this->assertSession()->pageTextContains(t('Test email submitted for delivery from test form.'));
 
     // Check rerouted email to.
     $this->assertMail('to', $this->rerouteDestination, new FormattableMarkup('To email address was rerouted to @address.', ['@address' => $this->rerouteDestination]));
diff --git a/tests/src/Functional/UnusualMessageFieldsTest.php b/tests/src/Functional/UnusualMessageFieldsTest.php
index 819816f..1a8c423 100644
--- a/tests/src/Functional/UnusualMessageFieldsTest.php
+++ b/tests/src/Functional/UnusualMessageFieldsTest.php
@@ -78,7 +78,7 @@ class UnusualMessageFieldsTest extends RerouteEmailTestBase {
 
     // Check the watchdog entry logged by reroute_email_test_mail_alter.
     $this->drupalGet('admin/reports/dblog');
-    $this->assertRaw(t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.');
+    $this->assertSession()->responseContains(t('A String was detected in the body'), 'Recorded in recent log messages: a String was detected in the body.');
 
     // Test the robustness of the CC and BCC keys in headers.
     $this->assertTrue($mail['headers']['X-Rerouted-Original-Cc'] == $test_message['params']['headers'][$test_cc_key], new FormattableMarkup('X-Rerouted-Original-Cc is correctly set to @test_cc_address, although Cc header message key provided was: @test_cc_key', [
