Start refactoring of namespaces

And add some more tests