complete unit tests for api, api fixes