Added more tests and refactored the servlet code a bit.