Big effort for moving directory specific tests into a flat hierarchy
under tests/. The reason for this is that it makes it easier to test
exports in future versions, as the tests are testing the entities outside
the top level module.

Also includes a bunch of minor fixes.