writing tests and adding exceptions