Some small changes on the API
Add some unit tests