minor refactor of flash(), improved tests for flash()