api refactoring and tests ready - Fixed #17