Make the tests runnable without relying on the root directory

Also do not "leak" file handles.
Add tests for redundant name mappings