fix connect_callback() so redirect is correct upon failure

This fixes Issue 18.

Since the result of the connect function was being handed directly to connect_handler, the redirect was being consumed as cv in connect_handler, rather than actually performing the redirect. Moving the check if cv is None outside of the connect function fixes the issue.