Rework tests and fix some bugs.
Update readme.