glue: ensure nested async calls have listeners set

Even if there are no callbacks on an asyncListener, the polyfill must
create a closure so that when the wrapped callback gets called, the
listeners that were active before the asynchronous call are activated
inside the callback. In the case when no listeners are active when
the wrapped function is called, don't wrap the callback so the active
listeners won't get overwritten when the callback is called.