More mouse handling fixes and tests