#38 unit tests and cleanup