some refactoring to servlet and tests