Added tests and addressed review comments