Fixed dynamic array allocation error.

And added some more test code.