fix tests and optional argument for reduce functions