All the usual contents of main() are put into this package for ease of testing.