Add tests for rank. Also fix root system An as using index -1 instead of 1.