refactor test handling