refactor test harness so it can be re-used