Wrap all modules in closures to prevent variable leaking

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>
Few more server-side tests

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>
Separate socket commands into their own modules

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>