Fix lookup and list bug for multiple registries.

Also improve and fix tests.

//cc @svnlto 

There are still some strange things in the tests such as abusing beforeEach and afterEach when after and before should be more appropriate.