Redmine#4848: fix peers, peerleader, and peerleaders functions and add tests