Fix #252: spurious unhandled rejections.

Calling `deferred.resolve()` then `deferred.reject()` would cause a spurious report of an unhandled rejection, because `deferred.reject()` worked by creating a rejected promise, even if `deferred.promise` was already resolved.

Also, clarified some variable names while I was there, like `resolvedPromise` instead of the deceptive `value`. This was especially confusing when the argument `value` to `resolve` and `fulfill` was shadowing the outer one.