added middleware
added tests
run tests