Added tests and adjusted exceptions