various fixes

* avoided use of the module() builtin to define the Lua module.
* rejected bad domain names with a leading dot.
* error handling fixes in the "query" and "tcp_query" methods.