Refactor common methods into lua_helpers.rb