Extract `appendView`, `destroyView` for testing

Defining `appendView` and `destroyView` in multiple tests is verbose,
repetitious, and copy-paste-error prone.
Merge pull request #9769 from seanpdoyle/view-helpers-extraction

Extract `appendView`, `destroyView` for testing