added unit testing and documentation