Add tests for module
Fix a bug that used the original length and not the new one transformed by modules