Address review comments and add UT for the new changes