added exception handling
added more unit test