Unit testing API

Start to write unit tests for the API