buffer/cursor: Handle EOF in ExtractCursor without crashing, add tests