Fix up the tests, refactor for clarity