[RFC] refactor includes + improve testing infrastructure

This will allows testing of more files and allow PR #904 to proceed.

Implements a tiny part of issue #918 in the process as well.