CON-2324 merge two functions into one and add unit tests