added unit tests and documentation