improve `get-service-fn`

* clean up signature
* error handling