Some tests require picking ports, and today resort to hard-coding, which is brittle. This patch adds a testlib.GetFreePort function to help pick free ports. It is not totally race-free, but is much better than hard-coding.