add error reporting & tests