Arrange for the JS code to initially run in an event loop thread, to avoid several different loops being created that could then execute code at the same time.

I also added a check to ensure that .end on an internal http client request is called only once, since NodeJS seems to tolerate that and I've caught npm modules doing it.
Merge pull request #58 from malaporte/fix-event-loop

Fix concurrency issues caused by JS callbacks running in different event loops