refactored API, refactored tests