Merge pull request #24 from DanielMorsing/priority

strengthen priority tree code and add tests