Allow runtime assignment of test ports and ensure consistency of async operations