refactored public interfaces and added tests