added unit tests and docs