Refactor test environment