Improve test logic of binding to a random open port