Dev codeclean

Clean up error code 
Add test for exception class