refactor to share testing infrastructure