Added exceptions and test for exceptions