added tests and custom exception