extract middleware and ditch configure call
use globals to simplify specs
use sinon-chai for better test double assertions