fixes #27 throw proper error and handle at top level
improved test to validate error is thrown