Updated tests to look for available ports dynamically