The flakiness happens because get() uses vim.schedule(), and a following key may be processed before the scheduled event. Use poke_eventloop() to ensure that the scheduled event is processed.