Add unit tests.

My suggestion was to return an new Error("API error: internal exception"). I suppose these errors are uncaught runtime exceptions from tooling, devappserver services, etc.

Nothing critical, we can leave them as they are.