refactored testing code