Refactor JSEnv to support async running

CI only so far. Will add commits as I go.