Rename "pending" variable to "messages."

This is purely an accuracy change:

- `pending` was not a good name, since the promise could be resolved but still pending even if `pending` was `undefined`.
- `messages` is more accurate since it contains the message names and parameters that will be forwarded to the resolved promise.
Clean up tests.