Fix bug with app context and tests