Cache: Bug fixes, tests added

Bug with page size recalc fixed.
Test for checking overflow behaviour added.
Function to clear cache added.