rename the function and simplify checking in junit