add error tests and better messages