Brushing up API and added tests.