Fixed issue #1460 against memory and paginated storage. Added a test case too.