Refactoring; add utility for testing flash messages