Fix Lua max_tries calculation

Fixes #32