further progress on unit tests caused some pretty major refactoring.