Enhanced ScriptUtils to log more information when script execution fails.
Merged code duplications.