Fix async init scripts being run in the wrong context

Fixes #373 by running the init function in the original script's context.