'net' module: tests and fixes

So far this updates #308 with a very basic test suite, and fixes IPv4 and/or IPv6 address detection.
(We might be able to avoid that situation with SO_REUSEADDR in the runtime (POSIX) version of tm_net, but I wasn't sure it was worth it and It's Complicated™: http://stackoverflow.com/a/14388707/179583)