test-lib-functions: introduce the 'test_set_port' helper function