Add test case for Pop().
Fix bugs.