Updated exception handling and added a few exception tests