tests: improved waiting for ports in junit test