Got first test passing after a load of refactoring.