Moving copypasted routines into lib/util
slightly refactoring createHarness()