Modifing a little the api and adding tests