Change buffer-contents from string to propertied string for detecting end of popup.
Refactoring all test cases