Builtin/common/misc_helpers: fix undeclared globals in functions. Shorten lines

Fixes warnings of undeclared globals in functions.