whoops typo
more tests
a bunch of refactoring/cleanup to make things more testable - lazy giant commit