EZP-22817: Error running legacy scripts

> Fixes https://jira.ez.no/browse/EZP-22817

Stored references to the handlers weren't properly passed to the closure, resulting in the kernel being rebooted. Since some feature, such as legacy scripts, rely on those references, they were broken.

The patch makes the closures use getter/setter methods on the loader to get previously created instances of the handlers.