Update api, add tests, make faster