Refactored API
Updated tests