adding unit tests and addressing PR comments