Add test to highlight bugf
Refactored remove_empty_modules, fixing a bug highlighted via test_utils.

Refs #7547