Implemented common logic and added few tests to SockJs