Added unit tests and comments.