unit tests and cleanup