refactored api and added tests