Create lots of new tests, refactor some code