added tests and exceptions