Refactor test with environment variables