factored out test code