Fixing a couple bugs with exception assertions and adding tests.