Major refactor
More tests