improved public api and added tests for all public api functions