Few bug fixes, more tests