Add initgration test and implemenation for distribute function.