Better error handling in webapp.
Added some webapp tests.