Unified code and tests for pvector