fix test-related warnings via refactoring

The test helpers were only being used inside the doctests, causing ghc
to think it wasn't being used. I have moved those helpers to a separate
file, whose import can be restricted to the test phase. I also include
them with the "()" option (no imports) during the regular compilation
phase, in order to obtain warnings from the helper module itself.