diff --git a/alfa-client/apps/admin-e2e/src/support/commands.ts b/alfa-client/apps/admin-e2e/src/support/commands.ts
index dca0eff2dde7f3eb6d78680255b177a0e6d34fc3..5442317e9972045e9b6be4644c4bbd5621377682 100644
--- a/alfa-client/apps/admin-e2e/src/support/commands.ts
+++ b/alfa-client/apps/admin-e2e/src/support/commands.ts
@@ -85,9 +85,7 @@ Cypress.Commands.add('getUserInfo', () => {
   return cy.request({
     method: HttpMethod.GET,
     url: `${getKeycloakBaseRealmUrl()}/userinfo`,
-    headers: {
-      [Header.AUTHORIZATION]: `bearer ${window.sessionStorage.getItem(ACCES_TOKEN)}`,
-    },
+    headers: { ...buildBearerTokenAuthorizationHeader() },
   });
 });
 
@@ -96,9 +94,7 @@ Cypress.Commands.add('findUser', (username: string) =>
     .request<UserRepresentation[]>({
       method: HttpMethod.GET,
       url: getUsersApiUrl(),
-      headers: {
-        [Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
-      },
+      headers: { ...buildBearerTokenAuthorizationHeader() },
     })
     .then<UserRepresentation>((response: Cypress.Response<UserRepresentation[]>) => {
       const users: UserRepresentation[] = response.body;
@@ -112,9 +108,7 @@ Cypress.Commands.add('verifyEmail', (userId: string) =>
   cy.request<void>({
     method: HttpMethod.PUT,
     url: getUsersApiUrl() + '/' + userId,
-    headers: {
-      [Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
-    },
+    headers: { ...buildBearerTokenAuthorizationHeader() },
     body: { emailVerified: true },
   }),
 );
@@ -123,13 +117,17 @@ Cypress.Commands.add('resetPassword', (userId: string, newPassword: string) =>
   cy.request<void>({
     method: HttpMethod.PUT,
     url: getUsersApiUrl() + '/' + userId + '/reset-password',
-    headers: {
-      [Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
-    },
+    headers: { ...buildBearerTokenAuthorizationHeader() },
     body: { type: 'password', temporary: false, value: newPassword },
   }),
 );
 
+function buildBearerTokenAuthorizationHeader(): object {
+  return {
+    [Header.AUTHORIZATION]: `Bearer ${getAccessToken()}`,
+  };
+}
+
 function getAccessToken(): string | null {
   return window.sessionStorage.getItem(ACCES_TOKEN);
 }