Refactor and also write in idiomatic lua

1. lua provides a meta-method __tostring for conversion to strings from other types
2. Put the expected value first, and the actual value second in assert statements
3. Replace if/then/else with regex that uses a quantifier ?, to ignore 1
4. Use string.gsub instead of string:gsub, to allow both strings and numbers in constructor