Refactor failover uri parse code