Tidy-up tests

Separates actual tests from helper modules and adds automatic test
discovery.