Refactored function tests to get rid of bad code smell