Add several tests; attempt to fix toArray method