Fix deselect publishing an event event if it wasnt previously selected.

Check previous value before enqueuing a deselect event.
Add tests for select and deselect events.