Fixing a few namespace bugs, adding tests.