i do not see why all these mocks are explicitly created here  if you need mock sock dup  you can do just mock sock dup mock listen return value dup return value this would avoid all unnecessary calls to different mocks 