Thank you for your help, Jan, I really appreciate it.
The solution you suggested solves the problem. However, I find that I would need to introduce the context module as an argument to be passed around to all predicates in the inference module, in order to be able to access the predicates defined in the test module.
This would be a not-so-elegant solution, so I kept on reading other posts on this forum and stumbled into this one If I understand correctly, Eric had a similar problem a year ago.
Your comment in the thread was “As is, this has no clean solution in the plain SWI-Prolog module system.”. Anyway, I will keep on studying along the lines you suggested, and try to find out if meta predicates could be used.