Pick a new random port if one is in use in functional tests

Fixes issue #113