improved error message, tests