generic_utils: addressed reviewer comment (and add unit test)