Added tests covering more code paths.
Added comments.