WFLY 2879 8.x - improvements to common code in test cases which use modules.

Backport from master.