[CDAP-774] Refactor and fix a bug in a unit test