some cleanup and unit tests