add unit test for midware