extract some helper function to simplify test