Adding more unit tests, refining the API.