updated tests to be passing, added extra error checking