Returns json errors on bad input.

Deleting the the db in tests is now via a temporary rest method.