Added unit tests, updated the documentation.