fixed a bug in VertexQueryOptimizer and added some test cases to validate its behavior.