refactored test code