fixed invalid read valgrind problems in TestDimension