Factored out test utilities.