anchor.diff:  
   list_groups_of_provider_test(Config) ->
       rest_test_utils:set_config(Config),
  -    {ok, User1} = oz_test_utils:create_user(Config, #od_user{name = <<"u1">>}),
  -    {ok, User2} = oz_test_utils:create_user(Config, #od_user{name = <<"u2">>}),
  -    {ok, User3} = oz_test_utils:create_user(Config, #od_user{name = <<"u3">>}),
  +    {ok, UserWithSpaces} = oz_test_utils:create_user(Config, #od_user{}),
       {ok, Provider, _} = oz_test_utils:create_provider(Config, <<"pr">>),
       % Users 1 and 2 belong to the spaces directly
       {ok, Space1} = oz_test_utils:create_space(
  -        Config, {user, User1}, <<"sp">>
  +        Config, {user, UserWithSpaces}, <<"sp">>
       ),
       {ok, Space2} = oz_test_utils:create_space(
  -        Config, {user, User2}, <<"sp">>
  -    ),
  -    {ok, Space3} = oz_test_utils:create_space(
  -        Config, {user, User2}, <<"sp">>
  -    ),
  -    % User 3 belongs to space 3 by nested groups
  -    ParentGroup = create_3_nested_groups(Config, User3),
  -    {ok, Space3} = oz_test_utils:add_member_to_space(
  -        Config, {group, ParentGroup}, Space3
  +        Config, {user, UserWithSpaces}, <<"sp">>
       ),
       {ok, _} = oz_test_utils:support_space(Config, Provider, Space1, 100),
       {ok, _} = oz_test_utils:support_space(Config, Provider, Space2, 100),
  -    {ok, _} = oz_test_utils:support_space(Config, Provider, Space3, 100),
  -    ExpUsers = [
  -        {User1, <<"u1">>},
  -        {User2, <<"u2">>},
  -        {User3, <<"u3">>}
  +
  +    % Dummy users are users are used to create nested groups
  +    {ok, DummyUser1} = oz_test_utils:create_user(Config, #od_user{}),
  +    {ok, DummyUser2} = oz_test_utils:create_user(Config, #od_user{}),
  +    {ok, DummyUser3} = oz_test_utils:create_user(Config, #od_user{}),
  +    % Create some groups
  +    {ok, SomeGroup} = oz_test_utils:create_group(
  +        Config, DummyUser3, <<"sgr">>
  +    ),
  +    {BottomGroup1, MiddleGroup1, TopGroup1} = create_3_nested_groups(
  +        Config, DummyUser1, <<"bgr1">>, <<"mgr1">>, <<"tgr1">>
  +    ),
  +    {BottomGroup2, MiddleGroup2, TopGroup2} = create_3_nested_groups(
  +        Config, DummyUser2, <<"bgr2">>, <<"mgr2">>, <<"2gr1">>
  +    ),
  +    % Add TopGroup2 to MiddleGroup1, now TopGroup1 has the following
  +    % effective groups:
  +    %   BottomGroup1,
  +    %   MiddleGroup1,
  +    %   BottomGroup2,
  +    %   MiddleGroup2,
  +    %   TopGroup2
  +    {ok, MiddleGroup2} = oz_test_utils:join_group(
  +        Config, {group, TopGroup2}, MiddleGroup1
  +    ),
  +    % Add the groups to spaces
  +    {ok, Space1} = oz_test_utils:add_member_to_space(
  +        Config, {group, TopGroup1}, Space1
  +    ),
  +    {ok, Space2} = oz_test_utils:add_member_to_space(
  +        Config, {group, SomeGroup}, Space2
  +    ),
  +    ExpGroups = [
  +        {SomeGroup, <<"sgr">>},
  +        {BottomGroup1, <<"bgr1">>},
  +        {MiddleGroup1, <<"mgr1">>},
  +        {TopGroup1, <<"tgr1">>},
  +        {BottomGroup2, <<"bgr2">>},
  +        {MiddleGroup2, <<"mgr2">>},
  +        {TopGroup2, <<"tgr2">>}
       ],
       % Admin will be used to grant or revoke privileges
       {ok, Admin} = oz_test_utils:create_user(Config, #od_user{}),
  
positive.code:         request => #{
              method => get,
              path => [<<"/providers/">>, ProviderId, <<"/spaces/">>, SpaceId],
              auth => Issuer
          },
          expect => #{
              code => Code,
              body => ExpectedBody
          }
      }).
  
  
  % Tries to list users of a provider and asserts if returned code and body
  % match the expected.
  check_list_users_of_provider(Code, Issuer, ProviderId, Users) ->
      ExpectedBody = case Users of
          undefined -> undefined;
          _ -> #{<<"users">> => Users}
      end,
      rest_test_utils:check_rest_call(#{
          request => #{
              method => get,
              path => [<<"/providers/">>, ProviderId, <<"/users">>],
              auth => Issuer
          },
          expect => #{
              code => Code,
              body => ExpectedBody
          }
      }).
  
  
  % Tries to get details of a certain user of provider and asserts if
  % returned code and body match the expected.
  check_get_user_of_provider_data(Code, Issuer, ProviderId, UserId, UserName) ->
      ExpectedBody = case UserName of
          undefined ->
              undefined;
          _ ->
              {contains, #{
                  <<"userId">> => UserId,
                  <<"name">> => UserName
              }}
      end,
      rest_test_utils:check_rest_call(#{
          request => #{
              method => get,
              path => [<<"/providers/">>, ProviderId, <<"/users/">>, UserId],
              auth => Issuer
          },
          expect => #{
  
negative.code: 
      % Add him to a nested group, which belongs to a group, which belongs to a
      % group that has the privileges and check if he can list providers.
      {_, _, TopGroup} = create_3_nested_groups(Config, TestUser),
      % The user should still not be able to list providers as the group
      % does not have privileges.
      ?assert(check_list_providers(403, TestUser, undefined)),
  