Address CR comments and fix unit tests