Add better unit tests (#148)

Refactor and clean up test code to speed up tests and run them in a truly cross-platform way.