Factor out dynamic function definition. Add test.
util: Rename function parameter.

to not clash with builtin name 'globals'.
Update changelog.

(Be more specific about improvements.)