Fixed typo.
Added tests and comments.