Add a UT to cover the changes
Fix a bug found in UT