move generic testing stuff into testlib