ticket:3 added unittests for middleware