slight updates and add tests and doc comments.