put assertion outside of the exception handler
use "with self.assertRaises" pattern
correct testcases
Merge pull request #1023 from zakkie/feature/fix-testcase

put assertion outside of the exception handler