Fixes test replaceFiresUpdatedEvent and some refactorings

Closes https://github.com/hazelcast/hazelcast/issues/3536

- Also includes refactoring of replace method and operation.