Merge base code and tests

Added base code and tests. Should be stable enough to be used, but still needs to be improved (adding new functions, more and better tests, etc).