Fix failing unit tests
Replace DBException.code with subclass hierarchy