Added tests for push, pop and merge, fixed several bugs using them.