[BUGFIX beta] Add cache tests and fix undefined value

cc @stefanpenner