Pulling out server functions to a helper and writing tests