Writing tests

In progress, but would probably benefit being in master. They're all green here at the mo...