Refactored test code