small fixes in test, and better exceptions