[REFACTOR] cleaner internal api and better unit test