Add server to engine and socketio, port more code form socketio depot
Fix the test case for engine handler