added unit tests and documentaiton