fix tests and add correct error handler
Merge pull request #1 from shime/master

fix tests and add correct error handler