Server: Refactor modules, complete REST API and add unit tests