Added some tests
Added exceptions
Some changes