Fix creation of class

Since the thread-safing, torch cannot create  Torch classes which do not belong to a module. It comes from commit c75931dd08. 

This pull-request fixes the problem and adds regression tests.

Example:

julien@hal:wta (wta %=)$ th
> x = torch.class('myclass')
/usr/local/torch/share/lua/5.1/torch/init.lua:54: while creating metatable myclass: bad argument #1 (myclass is an invalid module name)
stack traceback:
        [C]: in function 'newmetatable'
        /usr/local/torch/share/lua/5.1/torch/init.lua:54: in function 'class'
        [string "x = torch.class('myclass')..."]:1: in main chunk
        [C]: in function 'xpcall'
        /usr/local/torch/share/lua/5.1/trepl/init.lua:519: in function </usr/local/torch/share/lua/5.1/trepl/init.lua:426>
                                                                      [0.0001s]
> mymodule = {}
                                                                      [0.0001s]
> x = torch.class('mymodule.myclass')
     [0.0002s]
>