doctests and a better error message