Execution Object Sporadically Undefined in Script Task

Dear Flowable experts,

In some of our tests, we create script tasks using the following logic:

ScriptTask scriptTask = new ScriptTask();
scriptTask.setName("Script Task for result creation");
scriptTask.setId(SCRIPT_TASK_ID);
scriptTask.setScriptFormat("javascript");
scriptTask.setScript("execution.setVariable('result',true);");
scriptTask.setAsynchronous(async);
process.addFlowElement(scriptTask);

Most of the times, it works totally fine. However, every once in a while some of the tests fail and the root cause for the failure is as follows: "execution" is not defined in <eval> at line number 1

Looks like the execution object has not been initialized. What could be a reason for this?

Thank you!

Best,
Vasil