anchor.diff:            repo_subpath => <<"/path">>}
       ],
   
  -    {ok, Repos, Keys} = load_keys(KeyCfg, Repos, fun(K) -> mock_load_key(K) end),
  +    {ok, Repos, Keys} = load_keys(KeyCfg, RepoCfg, fun(K) -> mock_load_key(K) end),
   
  -    #{secret := Secret} = lists:last(Keys),
  +    {value, #{secret := Secret}} = lists:search(
  +        fun(#{id := Id}) -> Id =:= <<"test3.domain.org">> end, 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 | _] = binary:split(lists:last(binary:split(FileName, <<"/">>, [global])), <<".gw">>),
       #{id => Id, secret => <<"mocksecret">>, path => Path}.
  
positive.code:     end.
  
  
  -spec load_repos(RepoCfg) -> {ok, FixedRepoCfg}
      when RepoCfg :: [binary() | #{atom() => binary() | [binary()]}],
           FixedRepoCfg :: [#{atom() => binary() | [binary()]}].
  load_repos(RepoCfg) ->
      AddDefaultKeyId =
          fun(Name) when is_binary(Name) ->
                  #{domain => Name, keys => [Name]};
             (#{domain := _Name, keys := _Keys} = R) ->
                  R
          end,
  
negative.code:     ],
  
      {ok, Repos} = load_repos(RepoCfg),
      {value, #{domain := Name, keys := KeyIds}} = lists:search(
          fun(#{domain := D}) -> D =:= <<"test3.domain.org">> end, Repos),
      ?assert(Name =:= <<"test3.domain.org">>),
      ?assert(KeyIds =:= default),
  
      ok.
  
  load_keys_adds_missing_key_definition_test() ->
      RepoCfg = [
          #{domain => <<"test1.domain.org">>,
            keys => [<<"testkey1">>]},
          #{domain => <<"test2.domain.org">>,
            keys => [<<"testkey1">>, <<"testkey2">>]},
          #{domain => <<"test3.domain.org">>,
            keys => default}
      ],
      KeyCfg = [
          #{type => <<"plain_text">>,
  