Aggregate functions passing unit tests