modified middleware.rb and spec
cleaned up middle_ware spec