Fix implementation of getpriority (bad copy n paste), and improve test