fixed BinaryToDottedPort to handle IPv6, added tests, and made it more general