Refactor testutils