Added bound checks for privtopub, and fixed a bug in the test