Add test for toArray method