Fix EZP-21670: tests fixes and refactorings