Make things smaller

Bashed this into a shape that I'm happier with, in terms of adding tests, smaller, more testable things.