fix Memory and split tests and some refactor