Added Exceptions and Tests.