tighten error handling to raise some exceptions

closes #3
speed up tests