cleanup app state before a test too (rewrite of #1732)
cc @dandoveralba @bootstraponline