fix call the flush method
add tests for cases where cache table is not yet created