fix middleware unittest