In the case of ad-hoc processes (same thing for embedded supbrocesses), you have to explicitly say when you want to finish them by putting a End Event Node (not a terminating one). In your case, you need to attach a End Event Node to the Script Task inside the ad-hoc process.
About the test you are mentioning ( testAdHocSubProcess()), I'm not sure what test is that.
Best Regards,