Use custom error handlers in wrap-json functions

Currently default-handle-error is used even if a custom handler
has been passed in.
Add a unittest for custom error handlers
Clean up unit test
Merge pull request #1 from aykuznetsova/use-custom-handle-error

Use custom handle error