Problem: no unit tests for clojure server

Solution: add unit tests and restructure existing code for improved testability.