update code style

update code style for security patch: change the indentation
 from tab to 4 blank
update test cases to make them pass
Merge pull request #3 from tom-aa/backport_psycopg2_autocommit_fix

update code style and fix broken test cases