add test and more helpful error message