Reworking API, adding tests

API was redesigned to be more clean and consistent and actually follow
some sort of a design. Also we have a test now.
Reworking API and adding tests