Light refactoring, bug fix and regression test.
remote --> remotes
Merge pull request #9 from danvk/master

Light refactoring, bug fix and regression test