Move out some useful test functionality into its own module.