Make `entities.Repository.path` more robuts.

Made `entities.Repository.path` more robuts by checking if a valid `id`
is passed when ``which == 'sync'`` and added tests.