refactored test method