Added some more checks and tests and completed the pop_frame function
properly.