Minor fixes to unit test.

(1) Adding check to confirm the stack is empty after the traversal.
(2) Removing unused function.