refine the design of request processing; add tests