adding tests and dealing with exceptions