anchor.diff:      ],
   
       {ok, Repos} = load_repos(RepoCfg),
  -    #{domain := Name, keys := KeyIds} = lists:last(Repos),
  +    {value, #{domain := Name, keys := KeyIds}} = lists:search(
  +        fun(#{domain := D}) -> D =:= <<"test3.domain.org">> end, Repos),
       ?assert(Name =:= <<"test3.domain.org">>),
  -    ?assert(KeyIds =:= [<<"test3.domain.org">>]),
  +    ?assert(KeyIds =:= default),
   
       ok.
   
   load_keys_adds_missing_key_definition_test() ->
  -    Repos = [
  +    RepoCfg = [
           #{domain => <<"test1.domain.org">>,
             keys => [<<"testkey1">>]},
           #{domain => <<"test2.domain.org">>,
             keys => [<<"testkey1">>, <<"testkey2">>]},
           #{domain => <<"test3.domain.org">>,
  -          keys => [<<"test3.domain.org">>]}
  +          keys => default}
       ],
       KeyCfg = [
           #{type => <<"plain_text">>,
  
positive.code:           repo_subpath => <<"/path">>}
      ],
  
      {ok, Repos, Keys} = load_keys(KeyCfg, Repos, fun(K) -> mock_load_key(K) end),
  
      #{secret := Secret} = lists:last(Keys),
      ?assert(Secret =:= <<"mocksecret">>).
  
  mock_load_key(#{type := <<"plain_text">>, id := Id, secret := Secret, repo_subpath := Path}) ->
      #{id => Id, secret => Secret, path => Path};
  mock_load_key(#{type := <<"file">>, file_name := FileName, repo_subpath := Path}) ->
      Id = lists:last(binary:split(FileName, <<"/">>, [global])),
      #{id => Id, secret => <<"mocksecret">>, path => Path}.
  
negative.code: 
  
  load_keys(KeyCfg, Repos, KeyLoader) ->
      SpecifiedKeys = lists:map(KeyLoader, KeyCfg),
  
      ProcessDefaultKey = fun(R, {AccRepos, AccKeys}) ->
          #{domain := Name, keys := K} = R,
          case K of
              default ->
                  Key = KeyLoader(#{type => <<"file">>,
                                    file_name => <<"/etc/cvmfs/keys/", Name/binary, ".gw">>,
                                    repo_subpath => <<"/">>}),
                  #{id := KeyId} = Key,
                  case lists:search(fun(#{id := Id}) -> Id =:= KeyId end, SpecifiedKeys) of
                      false ->
                          {[#{domain => Name, keys => [KeyId]} | AccRepos],
                           [Key | AccKeys]};
                      _ ->
                          {[R | AccRepos], AccKeys}
                  end;
              _ ->
                  {[R | AccRepos], AccKeys}
          end
      end,
  
      {UpdatedRepos, DefaultKeys} = lists:foldl(ProcessDefaultKey, {[], []}, Repos),
      {ok, UpdatedRepos, SpecifiedKeys ++ DefaultKeys}.
  
  
  %%% Private functions
  