Improve TestShapeFunctions and TestShapeMatrices