fix cache bug on drop tail, add tests