fix active keybindings computation

it was attempting to throwing out c:m: keybindings under
windows but doing it incorrectly and so
also throwing out ~c:m: keybindings

also, refactor so that this code is more
testable now (and add some tests)