Bit more restructuring, fixing tests.

Signed-off-by: Ben Corlett <bencorlett@me.com>