Factored out test utility functions.