Fixed 2 issues with functions defined in Globals.

Also added a few tests to show the issues.

Issues:
 - If a global function returned a value, the value returned was a JS object instead of the correct data type.

 - A program would error if a function was defined in globals and the program had more than one plugin.