Refactor a bit to make testing easier
Boundary refactor, and add some tests
More boundary refactoring and testing
Only testing branch logic is so nice...