diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 0d80c36..009a3f0 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -418,9 +418,50 @@ protected function getAssertionCall() {
   }
 
   /**
-   * Check to see if a value is not false.
+   * Formats an assertion message.
    *
-   * False values are: empty string, 0, NULL, and FALSE.
+   * @param string $message
+   *   The assertion message, optionally containing string placeholders; e.g.,
+   *   '@first', '@second', '@value'.
+   * @param array $args
+   *   An associative array of replacement token mappings to pass to
+   *   format_string(). Replacement values of used tokens that are not strings
+   *   are dumped into the message via var_export(). Unused tokens are filtered
+   *   out.
+   *
+   * @return string
+   *   The formatted assertion message string.
+   */
+  protected function formatString($message, array $args) {
+    foreach ($args as $token => $value) {
+      // Filter out unused tokens and do not call var_export() for them.
+      // formatString() may be invoked from comparison methods like
+      // assertEqual() to which two large/complex objects have been passed for
+      // comparison, but the data may be too large to be exported or might
+      // contain recursions. In such cases, tests may specify custom assertion
+      // messages that omit the default tokens used in the default message.
+      if (strpos($message, $token) === FALSE) {
+        unset($args[$token]);
+        continue;
+      }
+
+      // @todo Remove all manual var_export() calls from tests and remove this.
+      if (!is_string($value)) {
+        $value = var_export($value, TRUE);
+      }
+
+      if (strpos($value, "\n")) {
+        $value = '<pre style="white-space: pre-wrap;">' . $value . '</pre>';
+      }
+
+      $args[$token] = $value;
+    }
+
+    return String::format($message, $args);
+  }
+
+  /**
+   * Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
    *
    * @param $value
    *   The value on which the assertion is to be done.
@@ -439,7 +480,13 @@ protected function getAssertionCall() {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertTrue($value, $message = '', $group = 'Other') {
-    return $this->assert((bool) $value, $message ? $message : String::format('Value @value is TRUE.', array('@value' => var_export($value, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @value is TRUE.';
+    }
+
+    return $this->assert((bool) $value, $this->formatString($message, array(
+      '@value' => $value,
+    )), $group);
   }
 
   /**
@@ -464,7 +511,13 @@ protected function assertTrue($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertFalse($value, $message = '', $group = 'Other') {
-    return $this->assert(!$value, $message ? $message : String::format('Value @value is FALSE.', array('@value' => var_export($value, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @value is FALSE.';
+    }
+
+    return $this->assert(!$value, $this->formatString($message, array(
+      '@value' => $value,
+    )), $group);
   }
 
   /**
@@ -487,7 +540,13 @@ protected function assertFalse($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNull($value, $message = '', $group = 'Other') {
-    return $this->assert(!isset($value), $message ? $message : String::format('Value @value is NULL.', array('@value' => var_export($value, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @value is NULL.';
+    }
+
+    return $this->assert(!isset($value), $this->formatString($message, array(
+      '@value' => $value,
+    )), $group);
   }
 
   /**
@@ -510,7 +569,13 @@ protected function assertNull($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotNull($value, $message = '', $group = 'Other') {
-    return $this->assert(isset($value), $message ? $message : String::format('Value @value is not NULL.', array('@value' => var_export($value, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @value is not NULL.';
+    }
+
+    return $this->assert(isset($value), $this->formatString($message, array(
+      '@value' => $value,
+    )), $group);
   }
 
   /**
@@ -535,7 +600,14 @@ protected function assertNotNull($value, $message = '', $group = 'Other') {
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertEqual($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first == $second, $message ? $message : String::format('Value @first is equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @first is equal to value @second.';
+    }
+
+    return $this->assert($first == $second, $this->formatString($message, array(
+      '@first' => $first,
+      '@second' => $second,
+    )), $group);
   }
 
   /**
@@ -560,7 +632,14 @@ protected function assertEqual($first, $second, $message = '', $group = 'Other')
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotEqual($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first != $second, $message ? $message : String::format('Value @first is not equal to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @first is not equal to value @second.';
+    }
+
+    return $this->assert($first != $second, $this->formatString($message, array(
+      '@first' => $first,
+      '@second' => $second,
+    )), $group);
   }
 
   /**
@@ -585,7 +664,14 @@ protected function assertNotEqual($first, $second, $message = '', $group = 'Othe
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertIdentical($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first === $second, $message ? $message : String::format('Value @first is identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @first is identical to value @second.';
+    }
+
+    return $this->assert($first === $second, $this->formatString($message, array(
+      '@first' => $first,
+      '@second' => $second,
+    )), $group);
   }
 
   /**
@@ -610,7 +696,14 @@ protected function assertIdentical($first, $second, $message = '', $group = 'Oth
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertNotIdentical($first, $second, $message = '', $group = 'Other') {
-    return $this->assert($first !== $second, $message ? $message : String::format('Value @first is not identical to value @second.', array('@first' => var_export($first, TRUE), '@second' => var_export($second, TRUE))), $group);
+    if (!$message) {
+      $message = 'Value @first is not identical to value @second.';
+    }
+
+    return $this->assert($first !== $second, $this->formatString($message, array(
+      '@first' => $first,
+      '@second' => $second,
+    )), $group);
   }
 
   /**
@@ -635,9 +728,9 @@ protected function assertNotIdentical($first, $second, $message = '', $group = '
    *   TRUE if the assertion succeeded, FALSE otherwise.
    */
   protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
-    $message = $message ?: String::format('!object1 is identical to !object2', array(
-      '!object1' => var_export($object1, TRUE),
-      '!object2' => var_export($object2, TRUE),
+    $message = $message ?: $this->formatString('!object1 is identical to !object2', array(
+      '!object1' => $object1,
+      '!object2' => $object2,
     ));
     $identical = TRUE;
     foreach ($object1 as $key => $value) {
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 61c54d1..52395f7 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -326,7 +326,7 @@ protected function drupalCreateContentType(array $values = array()) {
     $status = $type->save();
     \Drupal::service('router.builder')->rebuild();
 
-    $this->assertEqual($status, SAVED_NEW, String::format('Created content type %type.', array('%type' => $type->id())));
+    $this->assertEqual($status, SAVED_NEW, $this->formatString('Created content type %type.', array('%type' => $type->type)));
 
     // Reset permissions so that permissions for this content type are
     // available.
@@ -530,8 +530,8 @@ protected function drupalCreateUser(array $permissions = array(), $name = NULL)
     $account = entity_create('user', $edit);
     $account->save();
 
-    $this->assertTrue($account->id(), String::format('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
-    if (!$account->id()) {
+    $this->assertTrue(!empty($account->uid), $this->formatString('User created with name %name and pass %pass', array('%name' => $edit['name'], '%pass' => $edit['pass'])), 'User login');
+    if (empty($account->uid)) {
       return FALSE;
     }
 
@@ -583,9 +583,9 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL
     }
     $result = $role->save();
 
-    $this->assertIdentical($result, SAVED_NEW, String::format('Created role ID @rid with name @name.', array(
-      '@name' => var_export($role->label(), TRUE),
-      '@rid' => var_export($role->id(), TRUE),
+    $this->assertIdentical($result, SAVED_NEW, $this->formatString('Created role ID @rid with name @name.', array(
+      '@name' => $role->name,
+      '@rid' => $role->rid,
     )), 'Role');
 
     if ($result === SAVED_NEW) {
@@ -595,10 +595,10 @@ protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NUL
         $assigned_permissions = entity_load('user_role', $role->id())->permissions;
         $missing_permissions = array_diff($permissions, $assigned_permissions);
         if (!$missing_permissions) {
-          $this->pass(String::format('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
+          $this->pass($this->formatString('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), 'Role');
         }
         else {
-          $this->fail(String::format('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), 'Role');
+          $this->fail($this->formatString('Failed to create permissions: @perms', array('@perms' => implode(', ', $missing_permissions))), 'Role');
         }
       }
       return $role->id();
@@ -629,7 +629,7 @@ protected function checkPermissions(array $permissions, $reset = FALSE) {
     $valid = TRUE;
     foreach ($permissions as $permission) {
       if (!in_array($permission, $available)) {
-        $this->fail(String::format('Invalid permission %permission.', array('%permission' => $permission)), 'Role');
+        $this->fail($this->formatString('Invalid permission %permission.', array('%permission' => $permission)), 'Role');
         $valid = FALSE;
       }
     }
@@ -1256,7 +1256,7 @@ protected function curlExec($curl_options, $redirect = FALSE) {
       '@status' => $status,
       '!length' => format_size(strlen($this->drupalGetContent()))
     );
-    $message = String::format('!method @url returned @status (!length).', $message_vars);
+    $message = $this->formatString('!method @url returned @status (!length).', $message_vars);
     $this->assertTrue($this->drupalGetContent() !== FALSE, $message, 'Browser');
     return $this->drupalGetContent();
   }
@@ -1605,12 +1605,12 @@ protected function drupalPostForm($path, $edit, $submit, array $options = array(
       }
       // We have not found a form which contained all fields of $edit.
       foreach ($edit as $name => $value) {
-        $this->fail(String::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
+        $this->fail($this->formatString('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
       }
       if (!$ajax && isset($submit)) {
-        $this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
+        $this->assertTrue($submit_matches, $this->formatString('Found the @submit button', array('@submit' => $submit)));
       }
-      $this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
+      $this->fail($this->formatString('Found the requested form fields at @path', array('@path' => $path)));
     }
   }
 
@@ -2288,7 +2288,8 @@ protected function getAllOptions(\SimpleXMLElement $element) {
    */
   protected function assertLink($label, $index = 0, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
-    $message = ($message ?  $message : String::format('Link with label %label found.', array('%label' => $label)));
+    $message = ($message ?  $message : $this->formatString('Link with label %label found.', array('%label' => $label)));
+
     return $this->assert(isset($links[$index]), $message, $group);
   }
 
@@ -2314,7 +2315,7 @@ protected function assertLink($label, $index = 0, $message = '', $group = 'Other
    */
   protected function assertNoLink($label, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
-    $message = ($message ?  $message : String::format('Link with label %label not found.', array('%label' => $label)));
+    $message = ($message ?  $message : $this->formatString('Link with label %label not found.', array('%label' => $label)));
     return $this->assert(empty($links), $message, $group);
   }
 
@@ -2340,7 +2341,7 @@ protected function assertNoLink($label, $message = '', $group = 'Other') {
    */
   protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
-    $message = ($message ?  $message : String::format('Link containing href %href found.', array('%href' => $href)));
+    $message = ($message ?  $message : $this->formatString('Link containing href %href found.', array('%href' => $href)));
     return $this->assert(isset($links[$index]), $message, $group);
   }
 
@@ -2364,7 +2365,7 @@ protected function assertLinkByHref($href, $index = 0, $message = '', $group = '
    */
   protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
     $links = $this->xpath('//a[contains(@href, :href)]', array(':href' => $href));
-    $message = ($message ?  $message : String::format('No link containing href %href found.', array('%href' => $href)));
+    $message = ($message ?  $message : $this->formatString('No link containing href %href found.', array('%href' => $href)));
     return $this->assert(empty($links), $message, $group);
   }
 
@@ -2391,7 +2392,7 @@ protected function clickLink($label, $index = 0) {
       $url_target = $this->getAbsoluteUrl($urls[$index]['href']);
     }
 
-    $this->assertTrue(isset($urls[$index]), String::format('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
+    $this->assertTrue(isset($urls[$index]), $this->formatString('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
 
     if (isset($url_target)) {
       return $this->drupalGet($url_target);
@@ -2624,8 +2625,8 @@ protected function drupalSetSettings($settings) {
    */
   protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Current URL is @url.', array(
-        '@url' => var_export($this->container->get('url_generator')->generateFromPath($path, $options), TRUE),
+      $message = $this->formatString('Current URL is @url.', array(
+        '@url' => url($path, $options),
       ));
     }
     $options['absolute'] = TRUE;
@@ -2658,7 +2659,7 @@ protected function assertUrl($path, array $options = array(), $message = '', $gr
    */
   protected function assertRaw($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Raw "@raw" found', array('@raw' => $raw));
+      $message = $this->formatString('Raw "@raw" found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->drupalGetContent(), $raw) !== FALSE, $message, $group);
   }
@@ -2685,7 +2686,7 @@ protected function assertRaw($raw, $message = '', $group = 'Other') {
    */
   protected function assertNoRaw($raw, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Raw "@raw" not found', array('@raw' => $raw));
+      $message = $this->formatString('Raw "@raw" not found', array('@raw' => $raw));
     }
     return $this->assert(strpos($this->drupalGetContent(), $raw) === FALSE, $message, $group);
   }
@@ -2769,7 +2770,7 @@ protected function assertTextHelper($text, $message = '', $group, $not_exists) {
       $this->plainTextContent = filter_xss($this->drupalGetContent(), array());
     }
     if (!$message) {
-      $message = !$not_exists ? String::format('"@text" found', array('@text' => $text)) : String::format('"@text" not found', array('@text' => $text));
+      $message = !$not_exists ? $this->formatString('"@text" found', array('@text' => $text)) : $this->formatString('"@text" not found', array('@text' => $text));
     }
     return $this->assert($not_exists == (strpos($this->plainTextContent, $text) === FALSE), $message, $group);
   }
@@ -2885,7 +2886,7 @@ protected function assertUniqueTextHelper($text, $message = '', $group, $be_uniq
    */
   protected function assertPattern($pattern, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern));
+      $message = $this->formatString('Pattern "@pattern" found', array('@pattern' => $pattern));
     }
     return $this->assert((bool) preg_match($pattern, $this->drupalGetContent()), $message, $group);
   }
@@ -2910,7 +2911,7 @@ protected function assertPattern($pattern, $message = '', $group = 'Other') {
    */
   protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
     if (!$message) {
-      $message = String::format('Pattern "@pattern" not found', array('@pattern' => $pattern));
+      $message = $this->formatString('Pattern "@pattern" not found', array('@pattern' => $pattern));
     }
     return $this->assert(!preg_match($pattern, $this->drupalGetContent()), $message, $group);
   }
@@ -2936,9 +2937,9 @@ protected function assertNoPattern($pattern, $message = '', $group = 'Other') {
   protected function assertTitle($title, $message = '', $group = 'Other') {
     $actual = (string) current($this->xpath('//title'));
     if (!$message) {
-      $message = String::format('Page title @actual is equal to @expected.', array(
-        '@actual' => var_export($actual, TRUE),
-        '@expected' => var_export($title, TRUE),
+      $message = $this->formatString('Page title @actual is equal to @expected.', array(
+        '@actual' => $actual,
+        '@expected' => $title,
       ));
     }
     return $this->assertEqual($actual, $title, $message, $group);
@@ -2965,9 +2966,9 @@ protected function assertTitle($title, $message = '', $group = 'Other') {
   protected function assertNoTitle($title, $message = '', $group = 'Other') {
     $actual = (string) current($this->xpath('//title'));
     if (!$message) {
-      $message = String::format('Page title @actual is not equal to @unexpected.', array(
-        '@actual' => var_export($actual, TRUE),
-        '@unexpected' => var_export($title, TRUE),
+      $message = $this->formatString('Page title @actual is not equal to @unexpected.', array(
+        '@actual' => $actual,
+        '@unexpected' => $title,
       ));
     }
     return $this->assertNotEqual($actual, $title, $message, $group);
@@ -3148,20 +3149,20 @@ protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '', $g
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertFieldByName($name, $value = NULL, $message = NULL, $group = 'Browser') {
-    if (!isset($message)) {
+    if (!$message) {
       if (!isset($value)) {
-        $message = String::format('Found field with name @name', array(
-          '@name' => var_export($name, TRUE),
+        $message = $this->formatString('Found field with name @name', array(
+          '@name' => $name,
         ));
       }
       else {
-        $message = String::format('Found field with name @name and value @value', array(
-          '@name' => var_export($name, TRUE),
-          '@value' => var_export($value, TRUE),
+        $message = $this->formatString('Found field with name @name and value @value', array(
+          '@name' => $name,
+          '@value' => $value,
         ));
       }
     }
-    return $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, $group);
+    return $this->assertFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, 'Browser');
   }
 
   /**
@@ -3185,7 +3186,11 @@ protected function assertFieldByName($name, $value = NULL, $message = NULL, $gro
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoFieldByName($name, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message ? $message : String::format('Did not find field by name @name', array('@name' => $name)), $group);
+    if (!$message) {
+      $message = $this->formatString('Did not find field by name @name', array('@name' => $name));
+    }
+
+    return $this->assertNoFieldByXPath($this->constructFieldXpath('name', $name), $value, $message, $group);
   }
 
   /**
@@ -3209,7 +3214,11 @@ protected function assertNoFieldByName($name, $value = '', $message = '', $group
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertFieldById($id, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : String::format('Found field by id @id', array('@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Found field by id @id', array('@id' => $id));
+    }
+
+    return $this->assertFieldByXPath($this->constructFieldXpath('id', $id), $value, $message, $group);
   }
 
   /**
@@ -3233,7 +3242,11 @@ protected function assertFieldById($id, $value = '', $message = '', $group = 'Br
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoFieldById($id, $value = '', $message = '', $group = 'Browser') {
-    return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message ? $message : String::format('Did not find field by id @id', array('@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Did not find field by id @id', array('@id' => $id));
+    }
+
+    return $this->assertNoFieldByXPath($this->constructFieldXpath('id', $id), $value, $message, $group);
   }
 
   /**
@@ -3256,7 +3269,11 @@ protected function assertNoFieldById($id, $value = '', $message = '', $group = '
    */
   protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
-    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message ? $message : String::format('Checkbox field @id is checked.', array('@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Checkbox field @id is checked.', array('@id' => $id));
+    }
+
+    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['checked']), $message, $group);
   }
 
   /**
@@ -3279,7 +3296,11 @@ protected function assertFieldChecked($id, $message = '', $group = 'Browser') {
    */
   protected function assertNoFieldChecked($id, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//input[@id=:id]', array(':id' => $id));
-    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : String::format('Checkbox field @id is not checked.', array('@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Checkbox field @id is not checked.', array('@id' => $id));
+    }
+
+    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message, $group);
   }
 
   /**
@@ -3304,7 +3325,11 @@ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser')
    */
   protected function assertOption($id, $option, $message = '', $group = 'Browser') {
     $options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($options[0]), $message ? $message : String::format('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Option @option for field @id exists.', array('@option' => $option, '@id' => $id));
+    }
+
+    return $this->assertTrue(isset($options[0]), $message, $group);
   }
 
   /**
@@ -3330,7 +3355,11 @@ protected function assertOption($id, $option, $message = '', $group = 'Browser')
   protected function assertNoOption($id, $option, $message = '', $group = 'Browser') {
     $selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
     $options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : String::format('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id));
+    }
+
+    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message, $group);
   }
 
   /**
@@ -3357,7 +3386,11 @@ protected function assertNoOption($id, $option, $message = '', $group = 'Browser
    */
   protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : String::format('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id));
+    }
+
+    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message, $group);
   }
 
   /**
@@ -3382,7 +3415,11 @@ protected function assertOptionSelected($id, $option, $message = '', $group = 'B
    */
   protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser') {
     $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : String::format('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), $group);
+    if (!$message) {
+      $message = $this->formatString('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id));
+    }
+
+    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message, $group);
   }
 
   /**
@@ -3457,7 +3494,7 @@ protected function assertNoDuplicateIds($message = '', $group = 'Other', $ids_to
     foreach ($this->xpath('//*[@id]') as $element) {
       $id = (string) $element['id'];
       if (isset($seen_ids[$id]) && !in_array($id, $ids_to_skip)) {
-        $this->fail(String::format('The HTML ID %id is unique.', array('%id' => $id)), $group);
+        $this->fail($this->formatString('The HTML ID %id is unique.', array('%id' => $id)), $group);
         $status = FALSE;
       }
       $seen_ids[$id] = TRUE;
@@ -3503,7 +3540,14 @@ protected function constructFieldXpath($attribute, $value) {
   protected function assertResponse($code, $message = '', $group = 'Browser') {
     $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
-    return $this->assertTrue($match, $message ? $message : String::format('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
+    if ($message) {
+      $message = $this->formatString('HTTP response expected !code, actual !curl_code', array(
+        '!code' => $code,
+        '!curl_code' => $curl_code,
+      ));
+    }
+
+    return $this->assertTrue($match, $message, $group);
   }
 
   /**
@@ -3528,7 +3572,11 @@ protected function assertResponse($code, $message = '', $group = 'Browser') {
   protected function assertNoResponse($code, $message = '', $group = 'Browser') {
     $curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
-    return $this->assertFalse($match, $message ? $message : String::format('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
+    if (!$message) {
+      $message = $this->formatString('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code));
+    }
+
+    return $this->assertFalse($match, $message, $group);
   }
 
   /**
@@ -3596,9 +3644,14 @@ protected function assertMailString($field_name, $string, $email_depth, $message
         break;
       }
     }
+
     if (!$message) {
-      $message = format_string('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $string));
+      $message = $this->formatString('Expected text found in @field of email message: "@expected".', array(
+        '@field' => $field_name,
+        '@expected' => $string,
+      ));
     }
+
     return $this->assertTrue($string_found, $message, $group);
   }
 
@@ -3627,8 +3680,12 @@ protected function assertMailPattern($field_name, $regex, $message = '', $group
     $mail = end($mails);
     $regex_found = preg_match("/$regex/", $mail[$field_name]);
     if (!$message) {
-      $message = format_string('Expected text found in @field of email message: "@expected".', array('@field' => $field_name, '@expected' => $regex));
+      $message = $this->formatString('Expected text found in @field of email message: "@expected".', array(
+        '@field' => $field_name,
+        '@expected' => $regex,
+      ));
     }
+
     return $this->assertTrue($regex_found, $message, $group);
   }
 
