Bugfix for AbstractModules.replaceElements() 

Also added test files