Improve API
Fix tests