Rewrote utils.keyToLabel, fixes #32. Also added basic tests for it.