More unit tests and refactoring of servlet