make new functions for getting and testing random ports
replace _obtain_port() with new method