added tests to middleware