Executing the script:
in GroovyConsole breaks various functionality like output transformations and "Inspect Variables".
The GroovyConsole accesses the binding (context) of the internal shell via shell.context, thus leading to a call to shell.getProperty(). GroovyShell's getProperty() method however first tries to resolve against its variables. So if a variable with the name "context" is set, GroovyConsole uses its value, instead of the binding.
Replacing each occurence of shell.context with shell.getContext() should resolve the problem.