better error passing, more test coverage