Issue 56 resquash

This takes some previously unpushed changes for issue #56 and incorporates aagbsn's patch as well.

Open question:
 * does STREAM_DETACHED count as "closed" if we called Stream.close() and are waiting for confirmation from Tor?

@aagbsn does this look good?