Update api and example
Add tests