Fixed up test.lua, added a script to run it during the build

This depends on a number of commits from PR #1.