more tests, couple of bug fixes in api.