Added test and fixed bug with flatteining array arguments