Fix lint errors. Add tests for exceptions