Refactor for better unit tests