CLOUDSTACK-5748: Refactored code related to executing script