small changes to prim

quantile calculation is modified slightly and included in unit test.
Pasting is also modified to work correctly with new quantile calculation