Python3 test updates
Updates to the tests and library code to allow the tests to pass w/ python 2 or 3.
Also fixes a bug in the timeout handling. Once a connection has timed out, it must be closed. We throw away the state that would be needed to handle any data that arrives late.
Most of the changes involve byte/string/unicode differences between python 2 & 3.