fix tests and bug in distribute method. alse add some comments.