fix memory initializer counting and add test for merging of two of them