Fixed exception handling in disconnection test

OperationalError is DatabaseError's subclass.
Fixed range adaptation on Python 3