Moved api to separate file.
Added a few more functions and a new test.