Fixes random port testing problem

Fixes random port testing problem (#685).
@egbertbouman I had a quick talk with @whirm yesterday and we think it may be better to try random ports incrementally, so I made this. I am ok with either. @whirm Any suggestions?