diff --git a/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php b/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php
index 10c30b2144ce571e15f76c99ffd0528d38338cf5..7a4e82ac3c5beb8a84b33d08740d918e9b02ded2 100644
--- a/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php
+++ b/module/VuFind/src/VuFindTest/Unit/UserCreationTrait.php
@@ -28,6 +28,7 @@
  * @link     http://vufind.org/wiki/vufind2:unit_tests Wiki
  */
 namespace VuFindTest\Unit;
+use Behat\Mink\Element\Element;
 
 /**
  * Trait with utility methods for user creation/management. Assumes that it
@@ -64,6 +65,34 @@ trait UserCreationTrait
         }
     }
 
+    /**
+     * Mink support function: fill in the account creation form.
+     *
+     * @param Element $page      Page element.
+     * @param array   $overrides Optional overrides for form values.
+     *
+     * @return void
+     */
+    protected function fillInAccountForm(Element $page, $overrides = [])
+    {
+        $defaults = [
+            'firstname' => 'Tester',
+            'lastname' => 'McTestenson',
+            'email' => 'username1@ignore.com',
+            'username' => 'username1',
+            'password' => 'test',
+            'password2' => 'test'
+        ];
+
+        foreach ($defaults as $field => $default) {
+            $element = $page->findById('account_' . $field);
+            $this->assertNotNull($element);
+            $element->setValue(
+                isset($overrides[$field]) ? $overrides[$field] : $default
+            );
+        }
+    }
+
     /**
      * Static teardown support function to destroy user accounts. Accounts are
      * expected to exist, and the method will fail if they are missing.
@@ -87,7 +116,7 @@ trait UserCreationTrait
         foreach ((array)$users as $username) {
             $user = $userTable->getByUsername($username, false);
             if (empty($user)) {
-                throw new \Exception('Problem deleting expected user.');
+                throw new \Exception("Problem deleting expected user ($user).");
             }
             $user->delete();
         }
diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php
index 0e35be7a0c1466142c6d78b67467e2392d207a89..2409799b6cc1b5add7e08b9186c11567a1a2e844 100644
--- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php
+++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php
@@ -97,19 +97,13 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase
             $page->find('css', '.modal-body .btn.btn-primary.disabled')
         );
         $page->find('css', '.modal-body .btn.btn-primary')->click();
-        $this->assertNotNull($page->findById('account_firstname'));
+
         // Invalid email
-        $page->findById('account_firstname')->setValue('Tester');
-        $page->findById('account_lastname')->setValue('McTestenson');
-        $page->findById('account_email')->setValue('blargasaurus');
-        $page->findById('account_username')->setValue('username1');
-        $page->findById('account_password')->setValue('test');
-        $page->findById('account_password2')->setValue('test');
+        $this->fillInAccountForm($page, ['email' => 'blargasaurus']);
         $this->assertNull(
             $page->find('css', '.modal-body .btn.btn-primary.disabled')
         );
         $page->find('css', '.modal-body .btn.btn-primary')->click();
-        $this->assertNotNull($page->findById('account_firstname'));
         // Correct
         $page->findById('account_email')->setValue('username1@ignore.com');
         $page->find('css', '.modal-body .btn.btn-primary')->click();
@@ -230,19 +224,13 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase
             $page->find('css', '.modal-body .btn.btn-primary.disabled')
         );
         $page->find('css', '.modal-body .btn.btn-primary')->click();
-        $this->assertNotNull($page->findById('account_firstname'));
-        $page->findById('account_firstname')->setValue('Tester');
-        $page->findById('account_lastname')->setValue('McTestenson');
-        $page->findById('account_password')->setValue('test');
-        $page->findById('account_password2')->setValue('test');
-        $page->findById('account_username')->setValue('username2');
-        // Invalid email
-        $page->findById('account_email')->setValue('blargasaurus');
+        $this->fillInAccountForm(
+            $page, ['username' => 'username2', 'email' => 'blargasaurus']
+        );
         $this->assertNull(
             $page->find('css', '.modal-body .btn.btn-primary.disabled')
         );
         $page->find('css', '.modal-body .btn.btn-primary')->click();
-        $this->assertNotNull($page->findById('account_firstname'));
         $page->findById('account_email')->setValue('username2@ignore.com');
         // Test taken
         $page->findById('account_username')->setValue('username1');