Refactored testing codE