Added tests and code review comments