Add unit tests, cleanup.