Added tests, imporved exception messages