Make API pythonic, add tests