Refactored function tests