[RFC] refactor includes + improve testing infrastructure

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