this function is duplicated in tests and code, We would need to come out with a solution in order not to duplicate it. One option would be to move this utility functions to utils.misc