check for, and assign defer method to the right spot depending on enviro...

...nment.

The Promise.defer() method was being attached incorrectly.
 fixes issue #791 and references #781