Remove shadow copy paste error.
Add more unittests and comments.