Fix is_main checks for lua5.2

In lua5.2 package.loaded will be filled only when the module returns.
Therefore this cannot be used anymore to main-module checks.
Explicitly specify is_main module path
Add test for is_main()
Fixed issue for checking for "main" program under Lua 5.2.

Thanks to Thomas G. (coldfix) for providing a patch that I
slightly re-worked for the project.