More tests, more fixes, more consistent API