It should be possible to have 3 separate files: preloaded.ml, solution.ml, and tests.ml. It will be necessary to manually import preloaded code with open Preloaded (or using the Preloaded. prefix) and solution with open Solution. But all line numbers in error and warning messages will be correct for both user code and tests.