PROTON-760: Improve the JavaScript binding's internal Event loop and add additional tests.