Fixes, tests and improvements for array joining