Added an integration test: not working yet.
Tidy up. Refactored methods for rendering panels so they can be tested. Added tests.