fix missing requires in middleware
refactor specs
gardening