Extract function to pick node from backup list

* move external loop into the function
* allow to specify default port number

Change-Id: I90de13394a6becc1fe1baf7ed740af92df2466e6