Fixed a bug that approved test with Valgrind errors