Fixes random port testing problem

Fixes random port testing problem (#685).
Still, having this extra block of code just for the bind statement seems a bit much. Maybe it's usefull for debugging, but that doesn't mean it should be merged into devel.