More tests, beginning refactoring