I don't understand how unload_file/1 works with modules

What I don’t understand is what happens when a module file is unloaded and then reloaded. I thought I should be able to re-load a previously unloaded file without starting a new session, but that doesn’t seem to be the case. I show an example of this below:

Test module:

:-module(test_module, [def/0]).
def.

Some queries:

?- def.
true.

?- unload_file(test_module).
true.

?- def.
ERROR: Unknown procedure: def/0 (DWIM could not correct goal)

That’s as expected. But now what happens if I try to reload the previously unloaded module?

?- use_module(test_module).
true.

?- def.
ERROR: Unknown procedure: def/0 (DWIM could not correct goal)
?- listing(def).
ERROR: procedure `def' does not exist (DWIM could not correct goal)
^  Exception: (13) setup_call_catcher_cleanup(system:true, prolog_listing:listing_(user:def, []), _8646, prolog_listing:close_sources) ? abort
% Execution Aborted
?- test_module:def.
ERROR: Unknown procedure: test_module:def/0 (DWIM could not correct goal)

There was no error raised by use_module/1, yet the definition of def/0 in test_module is nowhere to be found in the program database. Is that the expected behaviour? Is there no way to reload the definitions of predicates in a previously unloaded module?

Why would I ever want to unload and then reload a module? To ensure that the definitions of predicates in that module are the ones actually defined in the module file and not added to the program database by some other process (i.e. by manipulating the dynamic database directly).

More generally, there are situations where I would like to be able to “refresh” my program database to the state it was in when a set of source files were initially loaded without having to start a new session. Is that possible?

Edit: Forgot to say. I’m using Swi on Windows with this version :

Welcome to SWI-Prolog (threaded, 64 bits, version 8.3.20)