Clean up some build details, add tests.