Fixed Lua 5.2 compatibility

Module semantics have changed in 5.2: a required file should not mess
with global environment anymore. LuaSocket and LuaPosix respect this
convention in 5.2 by not assigning themselves into globals.

This patch uses packages.loaded table to retrieve require results (simpler
the assigning pcall results into local variables).