Fix bug of removing pipe with the current priority

Fix typo and add a test for that.

The patch is submitted under MIT License