wip unit tests & refactoring
lots of library restructure / unit test work