Factored out some test code