Added test using unittest
Add test code
Added user-defined Exception class
fixed exception class