Add random port check

Main changes:
* Add check for random port generator.