Refactor connect func

Hello, I viewed source of psycopg2 recently and decided to perform minor refactor of connect function. Thx for useful project