squash this commit - more tests and refactoring