code review changes and added unit tests