diff --git a/core/modules/user/lib/Drupal/user/TempStore.php b/core/modules/user/lib/Drupal/user/TempStore.php
index c8a6dd1..666ebe4 100644
--- a/core/modules/user/lib/Drupal/user/TempStore.php
+++ b/core/modules/user/lib/Drupal/user/TempStore.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\user;
 
+use Drupal\Component\Utility\String;
 use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
 use Drupal\Core\Lock\LockBackendInterface;
 
@@ -138,9 +139,9 @@ function set($key, $value) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(format_string("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
+        throw new TempStoreException(String::format("Couldn't acquire lock to update item %key in %collection temporary storage.", array(
           '%key' => $key,
-          '%collection' => $this->storage->collection,
+          '%collection' => $this->storage->getCollectionName(),
         )));
       }
     }
@@ -184,9 +185,9 @@ function delete($key) {
     if (!$this->lockBackend->acquire($key)) {
       $this->lockBackend->wait($key);
       if (!$this->lockBackend->acquire($key)) {
-        throw new TempStoreException(format_string("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
+        throw new TempStoreException(String::format("Couldn't acquire lock to delete item %key from %collection temporary storage.", array(
           '%key' => $key,
-          '%collection' => $this->storage->collection,
+          '%collection' => $this->storage->getCollectionName(),
         )));
       }
     }
diff --git a/core/modules/user/tests/Drupal/user/Tests/TempStoreTest.php b/core/modules/user/tests/Drupal/user/Tests/TempStoreTest.php
new file mode 100644
index 0000000..217d893
--- /dev/null
+++ b/core/modules/user/tests/Drupal/user/Tests/TempStoreTest.php
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\TempStoreTest\TempStoreTest.
+ */
+
+namespace Drupal\user\Tests\TempStoreTest;
+
+use Drupal\Core\KeyValueStore\NullStorageExpirable;
+use Drupal\Tests\UnitTestCase;
+use Drupal\user\TempStore;
+
+/**
+ * Tests the user tempstore.
+ *
+ * @see \Drupal\user\Tempstore
+ */
+class TempStoreTest extends UnitTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'TempStore',
+      'description' => 'Tests the temporary object storage system.',
+      'group' => 'TempStore',
+    );
+  }
+
+  /**
+   * Tests lock on the set method.
+   *
+   * @expectedException \Drupal\user\TempStoreException
+   */
+  public function testLockedSet() {
+    $storage = new NullStorageExpirable('tempstore');
+    $lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
+
+    // Explicit ensure that the acquire method fails all the time.
+    $lock->expects($this->at(0))
+      ->method('acquire')
+      ->will($this->returnValue(FALSE));
+
+    $lock->expects($this->at(1))
+      ->method('acquire')
+      ->will($this->returnValue(FALSE));
+
+    $tempstore = new TempStore($storage, $lock, 1);
+    $tempstore->set('key', 'value');
+  }
+
+  /**
+   * Tests lock on the delete method.
+   *
+   * @expectedException \Drupal\user\TempStoreException
+   */
+  public function testLockedDelete() {
+    $storage = new NullStorageExpirable('tempstore');
+    $lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface');
+
+    // Explicit ensure that the acquire method fails all the time.
+    $lock->expects($this->at(0))
+      ->method('acquire')
+      ->will($this->returnValue(FALSE));
+
+    $lock->expects($this->at(1))
+      ->method('acquire')
+      ->will($this->returnValue(FALSE));
+
+    $tempstore = new TempStore($storage, $lock, 1);
+    $tempstore->delete('key');
+  }
+
+}
