[Utils] Fix a problem that the callback function is called synchronously in a condition.

This patch also fixes the test that is depending on the wrong behaivor.