Fixes generation of invalid ports (port < 1024), causing intermittent test failures in routing tests.