diff --git a/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php
index c37641c..6d303b5 100644
--- a/core/modules/comment/src/CommentStatistics.php
+++ b/core/modules/comment/src/CommentStatistics.php
@@ -115,7 +115,6 @@ public function create(FieldableEntityInterface $entity, $fields) {
       }
       // Get the user ID from the entity if it's set, or default to the
       // currently logged in user.
-      $last_comment_uid = 0;
       if ($entity instanceof EntityOwnerInterface) {
         $last_comment_uid = $entity->getOwnerId();
       }
@@ -125,7 +124,7 @@ public function create(FieldableEntityInterface $entity, $fields) {
         $last_comment_uid = $this->currentUser->id();
       }
       // Default to REQUEST_TIME when entity does not have a changed property.
-      $last_comment_timestamp = REQUEST_TIME;
+      $last_comment_timestamp = $_SERVER['REQUEST_TIME'];
       // @todo Make comment statistics language aware and add some tests. See
       //   https://www.drupal.org/node/2318875
       if ($entity instanceof EntityChangedInterface) {
diff --git a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
index c6f897a..b7781d0 100644
--- a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php
@@ -10,6 +10,7 @@
 use Drupal\comment\CommentStatistics;
 use Drupal\Tests\UnitTestCase;
 
+
 /**
  * @coversDefaultClass \Drupal\comment\CommentStatistics
  * @group comment
@@ -31,6 +32,13 @@ class CommentStatisticsUnitTest extends UnitTestCase {
   protected $select;
 
   /**
+   * Mock insert object.
+   *
+   * @var \Drupal\Core\Database\Query\Insert
+   */
+  protected $insert;
+
+  /**
    * Mock database connection.
    *
    * @var \Drupal\Core\Database\Connection
@@ -38,6 +46,34 @@ class CommentStatisticsUnitTest extends UnitTestCase {
   protected $database;
 
   /**
+   * Mock account interface for the user calling CommentStatistics methods.
+   *
+   * @var \Drupal\Core\Session\AccountInterface
+   */
+  protected $currentUser;
+
+  /**
+   * User ID returned by the mock user object. Should be set by tests.
+   *
+   * @var int
+   */
+  protected $currentUserId;
+
+  /**
+   * Values to be added to the mock database row store.
+   *
+   * @var array
+   */
+  protected $stagedInsertValues;
+
+  /**
+   * Mock database row store for comment_statistics table.
+   *
+   * @var array
+   */
+  protected $mockDatabaseStorage;
+
+  /**
    * CommentStatistics service under test.
    *
    * @var \Drupal\comment\CommentStatisticsInterface
@@ -55,6 +91,13 @@ class CommentStatisticsUnitTest extends UnitTestCase {
    * Sets up required mocks and the CommentStatistics service under test.
    */
   protected function setUp() {
+
+    $this->database = $this->getMockBuilder('Drupal\Core\Database\Connection')
+      ->disableOriginalConstructor()
+      ->getMock();
+
+    // Set up mock objects for database select.
+
     $this->statement = $this->getMockBuilder('Drupal\Core\Database\Driver\sqlite\Statement')
       ->disableOriginalConstructor()
       ->getMock();
@@ -79,15 +122,39 @@ protected function setUp() {
       ->method('execute')
       ->will($this->returnValue($this->statement));
 
-    $this->database = $this->getMockBuilder('Drupal\Core\Database\Connection')
+    $this->database->expects($this->any())
+      ->method('select')
+      ->will($this->returnValue($this->select));
+
+    // Set up mock objects for database insert.
+
+    $this->insert = $this->getMockBuilder('Drupal\Core\Database\Query\Insert')
       ->disableOriginalConstructor()
       ->getMock();
 
-    $this->database->expects($this->once())
-      ->method('select')
-      ->will($this->returnValue($this->select));
+    $this->insert->expects($this->any())
+      ->method('fields')
+      ->will($this->returnSelf());
+
+    $this->insert->expects($this->any())
+      ->method('values')
+      ->will($this->returnCallback(array($this, 'stageValuesCallback')));
 
-    $this->commentStatistics = new CommentStatistics($this->database, $this->getMock('Drupal\Core\Session\AccountInterface'), $this->getMock('Drupal\Core\Entity\EntityManagerInterface'), $this->getMock('Drupal\Core\State\StateInterface'));
+    $this->insert->expects($this->any())
+      ->method('execute')
+      ->will($this->returnCallback(array($this, 'updateValuesCallback')));
+
+    $this->database->expects($this->any())
+      ->method('insert')
+      ->will($this->returnValue($this->insert));
+
+    // Set up mock account which can be told what ID it has
+    $this->currentUser = $this->getMock('Drupal\Core\Session\AccountInterface');
+    $this->currentUser->expects($this->any())
+      ->method('id')
+      ->will($this->returnCallback(array($this, 'currentUserIdCallback')));
+
+    $this->commentStatistics = new CommentStatistics($this->database, $this->currentUser, $this->getMock('Drupal\Core\Entity\EntityManagerInterface'), $this->getMock('Drupal\Core\State\StateInterface'));
   }
 
   /**
@@ -105,6 +172,101 @@ public function testRead() {
   }
 
   /**
+   * Tests the create method, by a mock class with EntityOwnerInterface.
+   *
+   * @see \Drupal\comment\CommentStatistics::create()
+   *
+   * @group Drupal
+   * @group Comment
+   */
+  public function testCreateEntityWithOwnerInterface() {
+    $entity = $this->getMockBuilder('Drupal\node\Entity\Node')
+      ->disableOriginalConstructor()
+      ->getMock();
+
+    if ($this->createEntity($entity, 'node', 234, 2)) {
+      // Statistics should get the entity's owner id as last_comment_uid.
+      $this->assertEquals(2, $this->mockDatabaseStorage['node:234:field_testcomment']['last_comment_uid']);
+    }
+  }
+
+  /**
+   * Tests the create method, by a mock class without EntityOwnerInterface.
+   *
+   * @see \Drupal\comment\CommentStatistics::create()
+   *
+   * @group Drupal
+   * @group Comment
+   */
+  public function testCreateEntityWithoutOwnerInterface() {
+    $entity = $this->getMock('Drupal\user\UserInterface');
+
+    // Initialize 'current user' value to use while inserting statistics record.
+    $this->currentUserId = 5;
+    if ($this->createEntity($entity, 'user', 345, 3)) {
+      // Statistics should get current user id as last_comment_uid.
+      $this->assertEquals(5, $this->mockDatabaseStorage['user:345:field_testcomment']['last_comment_uid']);
+    }
+  }
+
+  /**
+   * Inserts a mock statistics row for an entity.
+   *
+   * @param object $entity
+   *   Entity mock object
+   * @param string $type
+   *   Entity type
+   * @param int $id
+   *   Entity ID
+   * @param int $uid
+   *   Entity owner ID
+   *
+   * @return bool
+   *   TRUE if no tests failed inside this method.
+   *
+   * @see \Drupal\comment\CommentStatistics::create()
+   *
+   * @group Drupal
+   * @group Comment
+   */
+  protected function createEntity($entity, $type, $id, $uid) {
+
+    // Assign various values. OwnerID is for the test; others are unimportant.
+    $entity->expects($this->any())
+      ->method('getEntityTypeId')
+      ->will($this->returnValue($type));
+
+    $entity->expects($this->any())
+      ->method('getOwnerId')
+      ->will($this->returnValue($uid));
+
+    $entity->expects($this->any())
+      ->method('id')
+      ->will($this->returnValue($id));
+
+    $entity->expects($this->any())
+      ->method('getChangedTime')
+      ->will($this->returnValue(time()));
+
+    // Every field we pass to create, will 'be present in $entity'.
+    $entity->expects($this->any())
+      ->method('hasField')
+      ->will($this->returnValue(TRUE));
+
+    // We assume $fields values are not used; the create() call signature is
+    // like it is, only because it mirrors hook_entity_storage_load().
+    $fields = array('field_testcomment' => NULL);
+    $this->commentStatistics->create($entity, $fields);
+
+    if (!isset($this->mockDatabaseStorage["$type:$id:field_testcomment"]['last_comment_uid'])) {
+      $this->fail("No statistics record or last comment ID was stored for $type:$id:field_testcomment.");
+      return FALSE;
+    }
+
+    return TRUE;
+  }
+
+  /**
    * Return value callback for fetchObject() function on mocked object.
    *
    * @return bool|string
@@ -125,4 +287,43 @@ public function fetchObjectCallback() {
         break;
     }
   }
+
+  /**
+   * Return value callback for values() function on mocked Insert.
+   *
+   * @return \Drupal\Core\Database\Query\Insert
+   *   The mocked Insert object on which values() was called.
+   */
+  public function stageValuesCallback($values) {
+    $this->stagedInsertValues = $values;
+    // return 'self'.
+    return $this->insert;
+  }
+
+  /**
+   * Return value callback for execute() function on mocked Insert object.
+   *
+   * @return int
+   *   Zero. (An invalid 'insert id'. It's expected not to be used.)
+   */
+  public function updateValuesCallback() {
+    // This method just assumes it's always being called immediately after
+    // another 'stage values' callback, that all required values are present,
+    // and that an insert won't try to set duplicate rows.
+    $vals = $this->stagedInsertValues;
+    $pkey = "$vals[entity_type]:$vals[entity_id]:$vals[field_name]";
+    $this->mockDatabaseStorage[$pkey] = $vals;
+    return 0;
+  }
+
+  /**
+   * Return value callback for id() function on mocked User.
+   *
+   * @return int
+   *   A user ID, which should be set beforehand by a test method as needed.
+   */
+  public function currentUserIdCallback() {
+    return isset($this->currentUserId) ? $this->currentUserId : 999;
+  }
+
 }
