improve api and complete integration tests