anchor.diff:  
   %% Group privileges tests
   
  -group_privileges_check([], _, _, _, _) -> ok;
  -group_privileges_check([FirstPrivilege | Privileges], UserData1, UserData2, GID, _SID) ->
  -    ?PRINT("PRIVILIGE"),
  -    ?PRINT([FirstPrivilege]),
  -    group_privileges_check(FirstPrivilege,  UserData1, UserData2, GID, _SID),
  -    ?PRINT("BACK"),
  +
  +group_privileges_check([group_view_data], UserData1, UserData2, GID, _SID) ->
       {UserId1, UserReqParams1} = UserData1,
       {UserId2, UserReqParams2} = UserData2,
  +
       get_group_user_privileges(GID, UserId1, UserReqParams1),
       get_group_user_privileges(GID, UserId2, UserReqParams1),
  -    group_privileges_check(Privileges, UserData1, UserData2, GID, _SID);
  -group_privileges_check(group_view_data, UserData1, UserData2, GID, _SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -    ?PRINT(UserId1),
  -    ?PRINT(UserId2),
  -
  -    %% user who belongs to group should have group_view_data privilege by default
  -
  +
  +     %% test if user2 lacks group_change_data privileges
  +    ?assertMatch(
  +        bad,
  +        check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  +    ),
  +
  +    ?PRINT("SET SET SET"),
  +%% TODO uncomment below lines after finding bug in setting priviliges
  +
  +    set_group_user_privileges(GID, UserId2, [group_view_data], UserReqParams1),
  +
  +    ?assertMatch(
  +        ok,
  +        check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  +    ),
       get_group_user_privileges(GID, UserId1, UserReqParams1),
       get_group_user_privileges(GID, UserId2, UserReqParams1),
  -
  -    ?assertMatch(
  -        [GID, ?GROUP_NAME1],
  -        read_group(GID, UserReqParams2)
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1),
  -    get_group_user_privileges(GID, UserId1, UserReqParams1),
  -    get_group_user_privileges(GID, UserId2, UserReqParams1);
  -group_privileges_check(group_change_data, UserData1, UserData2, GID, _SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -     %% test if user2 lacks group_change_data privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  -    ),
  -
  -    ?PRINT("SETTING PRIVILEGES"),
  -%% TODO uncomment below lines after finding bug in setting priviliges
  -    
  -%%     set_group_user_privileges(GID, UserId2, [group_change_data], UserReqParams1),
  +    clean_group_privileges(GID, UserId2, UserReqParams1),
  +    ok.
  +
  +%% group_privileges_check([], _, _, _, _) -> ok;
  +%% group_privileges_check([FirstPrivilege | Privileges], UserData1, UserData2, GID, _SID) ->
  +%%     ?PRINT("PRIVILEGE"),
  +%%     ?PRINT(FirstPrivilege),
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     get_group_user_privileges(GID, UserId1, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId2, UserReqParams1),
  +%%     group_privileges_check(FirstPrivilege,  UserData1, UserData2, GID, _SID),
  +%%     ?PRINT("BACK"),
  +%%
  +%%     get_group_user_privileges(GID, UserId1, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId2, UserReqParams1),
  +%%     group_privileges_check(Privileges, UserData1, UserData2, GID, _SID);
  +%% group_privileges_check(group_view_data, UserData1, UserData2, GID, _SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%     ?PRINT(UserId1),
  +%%     ?PRINT(UserId2),
  +%%
  +%%     %% user who belongs to group should have group_view_data privilege by default
  +%%
  +%%     get_group_user_privileges(GID, UserId1, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId2, UserReqParams1),
  +%%
  +%%     ?assertMatch(
  +%%         [GID, ?GROUP_NAME1],
  +%%         read_group(GID, UserReqParams2)
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId1, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId2, UserReqParams1);
  +%% group_privileges_check(group_change_data, UserData1, UserData2, GID, _SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%      %% test if user2 lacks group_change_data privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  +%%     ),
  +%%
  +%%     ?PRINT("SETTING PRIVILEGES"),
  +%% %% TODO uncomment below lines after finding bug in setting priviliges
  +%%
  +%% %%     set_group_user_privileges(GID, UserId2, [group_change_data], UserReqParams1),
  +%% %%
  +%% %%     ?assertMatch(
  +%% %%         ok,
  +%% %%         check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  +%% %%     ),
  +%%     get_group_user_privileges(GID, UserId1, UserReqParams1),
  +%%     get_group_user_privileges(GID, UserId2, UserReqParams1),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%% group_privileges_check(group_invite_user, UserData1, UserData2, GID, _SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%      %% test if user2 lacks group_invite_user privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(get_group_invitation_token(GID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_invite_user], UserReqParams1),
  +%%
  +%%     ?assertNotMatch(
  +%%         ok,
  +%%         get_group_invitation_token(GID, UserReqParams2)
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%% group_privileges_check(group_set_privileges, UserData1, UserData2, GID, _SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%      %% test if user2 lacks group_set_privileges privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(set_group_user_privileges(GID, UserId1, ?GROUP_PRIVILEGES, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_set_privileges], UserReqParams1),
   %%
   %%     ?assertMatch(
   %%         ok,
  -%%         check_status(update_group(GID, ?GROUP_NAME2, UserReqParams2))
  +%%         check_status(set_group_user_privileges(GID, UserId1, ?GROUP_PRIVILEGES, UserReqParams2))
   %%     ),
  -    get_group_user_privileges(GID, UserId1, UserReqParams1),
  -    get_group_user_privileges(GID, UserId2, UserReqParams1),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -group_privileges_check(group_invite_user, UserData1, UserData2, GID, _SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -     %% test if user2 lacks group_invite_user privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(get_group_invitation_token(GID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_invite_user], UserReqParams1),
  -
  -    ?assertNotMatch(
  -        ok,
  -        get_group_invitation_token(GID, UserReqParams2)
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -group_privileges_check(group_set_privileges, UserData1, UserData2, GID, _SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -     %% test if user2 lacks group_set_privileges privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(set_group_user_privileges(GID, UserId1, ?GROUP_PRIVILEGES, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_set_privileges], UserReqParams1),
  -
  -    ?assertMatch(
  -        ok,
  -        check_status(set_group_user_privileges(GID, UserId1, ?GROUP_PRIVILEGES, UserReqParams2))
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -
  -group_privileges_check(group_join_space, UserData1, UserData2, GID, SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -    InvitationToken = get_space_invitation_token(groups, GID, UserReqParams2),
  -
  -     %% test if user2 lacks group_join_space privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(join_group_to_space(InvitationToken, SID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_join_space], UserReqParams1),
  -
  -    ?assertMatch(
  -        SID,
  -        check_status(join_group_to_space(InvitationToken, GID, UserReqParams2))
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -
  -group_privileges_check(group_leave_space, UserData1, UserData2, GID, SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -    InvitationToken = get_space_invitation_token(groups, SID, UserReqParams2),
  -
  -    set_group_user_privileges(GID, UserId2, [group_join_space], UserReqParams1),
  -
  -    ?assertMatch(
  -        ok,
  -        check_status(join_group_to_space(InvitationToken, GID, UserReqParams2))
  -    ),
  -    %% test if user2 lacks group_leave_space privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(group_leave_space(GID, SID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_join_space, group_leave_space], UserReqParams1),
  -    ?assertMatch(
  -        ok,
  -        check_status(group_leave_space(GID, SID, UserReqParams2))
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -
  -group_privileges_check(group_create_space_token, UserData1, UserData2, GID, SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -    %% test if user2 lacks group_create_space_token privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(get_space_creation_token_for_group(GID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_create_space_token, group_leave_space], UserReqParams1),
  -
  -    ?assertNotMatch(
  -        bad,
  -        check_status(get_space_creation_token_for_group(GID, UserReqParams2))
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -
  -group_privileges_check(group_create_space_token, UserData1, UserData2, GID, SID) ->
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -    %% test if user2 lacks group_create_space_token privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(create_space_for_group(?SPACE_NAME2, GID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_create_space], UserReqParams1),
  -
  -    ?assertNotMatch(
  -        bad,
  -        check_status(create_space_for_group(?SPACE_NAME2, GID, UserReqParams2))
  -    ),
  -    clean_privileges(GID, UserId2, UserReqParams1);
  -
  -group_privileges_check(group_remove_user, UserData1, UserData2, GID, _SID) ->
  -    group_privileges_check(group_remove, UserData1, UserData2, GID, _SID);
  -
  -group_privileges_check(group_remove, UserData1, UserData2, GID, _SID) ->
  -
  -    {UserId1, UserReqParams1} = UserData1,
  -    {UserId2, UserReqParams2} = UserData2,
  -
  -    %% test if user2 lacks group_remove_user privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(delete_group_user(GID, UserId1, UserReqParams2))
  -    ),
  -
  -    %% test if user2 lacks group_remove privileges
  -    ?assertMatch(
  -        bad,
  -        check_status(delete_group(GID, UserReqParams2))
  -    ),
  -
  -    set_group_user_privileges(GID, UserId2, [group_remove_user, group_remove], UserReqParams1),
  -
  -    %% test if user2 lacks group_remove_user privileges
  -    ?assertMatch(
  -        ok,
  -        check_status(delete_group_user(GID, UserId1, UserReqParams2))
  -    ),
  -
  -    %% test if user2 lacks group_remove privileges
  -    ?assertMatch(
  -        ok,
  -        check_status(delete_group(GID, UserReqParams2))
  -    ).
  -
  -clean_privileges(GID, UserId, ReqParams) ->
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%%
  +%% group_privileges_check(group_join_space, UserData1, UserData2, GID, SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     InvitationToken = get_space_invitation_token(groups, GID, UserReqParams2),
  +%%
  +%%      %% test if user2 lacks group_join_space privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(join_group_to_space(InvitationToken, SID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_join_space], UserReqParams1),
  +%%
  +%%     ?assertMatch(
  +%%         SID,
  +%%         check_status(join_group_to_space(InvitationToken, GID, UserReqParams2))
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%%
  +%% group_privileges_check(group_leave_space, UserData1, UserData2, GID, SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     InvitationToken = get_space_invitation_token(groups, SID, UserReqParams2),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_join_space], UserReqParams1),
  +%%
  +%%     ?assertMatch(
  +%%         ok,
  +%%         check_status(join_group_to_space(InvitationToken, GID, UserReqParams2))
  +%%     ),
  +%%     %% test if user2 lacks group_leave_space privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(group_leave_space(GID, SID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_join_space, group_leave_space], UserReqParams1),
  +%%     ?assertMatch(
  +%%         ok,
  +%%         check_status(group_leave_space(GID, SID, UserReqParams2))
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%%
  +%% group_privileges_check(group_create_space_token, UserData1, UserData2, GID, SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     %% test if user2 lacks group_create_space_token privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(get_space_creation_token_for_group(GID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_create_space_token, group_leave_space], UserReqParams1),
  +%%
  +%%     ?assertNotMatch(
  +%%         bad,
  +%%         check_status(get_space_creation_token_for_group(GID, UserReqParams2))
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%%
  +%% group_privileges_check(group_create_space_token, UserData1, UserData2, GID, SID) ->
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     %% test if user2 lacks group_create_space_token privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(create_space_for_group(?SPACE_NAME2, GID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_create_space], UserReqParams1),
  +%%
  +%%     ?assertNotMatch(
  +%%         bad,
  +%%         check_status(create_space_for_group(?SPACE_NAME2, GID, UserReqParams2))
  +%%     ),
  +%%     clean_privileges(GID, UserId2, UserReqParams1);
  +%%
  +%% group_privileges_check(group_remove_user, UserData1, UserData2, GID, _SID) ->
  +%%     group_privileges_check(group_remove, UserData1, UserData2, GID, _SID);
  +%%
  +%% group_privileges_check(group_remove, UserData1, UserData2, GID, _SID) ->
  +%%
  +%%     {UserId1, UserReqParams1} = UserData1,
  +%%     {UserId2, UserReqParams2} = UserData2,
  +%%
  +%%     %% test if user2 lacks group_remove_user privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(delete_group_user(GID, UserId1, UserReqParams2))
  +%%     ),
  +%%
  +%%     %% test if user2 lacks group_remove privileges
  +%%     ?assertMatch(
  +%%         bad,
  +%%         check_status(delete_group(GID, UserReqParams2))
  +%%     ),
  +%%
  +%%     set_group_user_privileges(GID, UserId2, [group_remove_user, group_remove], UserReqParams1),
  +%%
  +%%     %% test if user2 lacks group_remove_user privileges
  +%%     ?assertMatch(
  +%%         ok,
  +%%         check_status(delete_group_user(GID, UserId1, UserReqParams2))
  +%%     ),
  +%%
  +%%     %% test if user2 lacks group_remove privileges
  +%%     ?assertMatch(
  +%%         ok,
  +%%         check_status(delete_group(GID, UserReqParams2))
  +%%     ).
  +
  +clean_group_privileges(GID, UserId, ReqParams) ->
       set_group_user_privileges(GID, UserId, [group_view_data], ReqParams).
  +
  
positive.code:             RestAddress ++ "/spaces/" ++ binary_to_list(SID) ++ "/providers",
              Headers, get, [], Options
          ),
  %%     TODO remove below print
      ?PRINT(Response),
      [Providers] = get_body_val([providers], Response),
   Providers.
  %%
  %%
  get_space_provider(SID, PID, ReqParams) ->
  {RestAddress, Headers, Options} = ReqParams,
      Response =
  
negative.code:     ),
  
      ?assertMatch(
          false,
          is_included([SID2], get_group_spaces(GID, UserReqParams1))
      ).
  
  %% spaces_rest_module_test_group =======================================
  