split code into api and logic (lib)

this way a cli can be added and used even when having a running api instance
write spec descriptions for tests
refactor api tests
add tests for secrets api