Set the state before calling #enter and #exit

Querying the state from inside an enter method doesn't return the state that the enter filter is called from. This patch sets the state before calling enter.