Added test case.
Fixed bug with duplicate probabilities