fix middleware exception bubbling. add config tests