[TASK] Introducing DatabaseConnection mocking (for cache DB backend etc.)
[TASK] Adding tests for PageLayoutView hook

This changes also come with some minor refactorings, separating
view logic for better maintainability.