Fix of race condition in replication/memcached.test, some code cleanup
Merge branch 'tt-mem-repl-fix' into stable