fixed bugs in pio test and pio code