Refactor test utils