make flash middleware implements countable

see #640