Improve Lua filter glue.

With these changes https://poolp.org/~sunil/test.lua works with all the state transitions.