Adds test of toArray.
Adds implementation of toArray.
Adding test of toArray with typed array.
Adds implementation of typed toArray.