Rewrite TestUtils.getNextAvailablePort to use randomisation.