Add unit tests.

python and java exception doesn't have much context and could be confusing. Why don't we return a more catch-all error message for them?