Make `wait()` return a resolved promise when a BRS is closed.

Fixes #80. Adds a few illustrative test cases showing how this was actually a pretty bad bug, as all the example code was written assuming a resolved promise whereas the spec mandated a rejected one. (Note that the `getNext` example was messed up anyway due to lack of EOF signifier; this commit rewrites it.)