graph: validate tags properly & add unit tests

`docker pull -a debian` was failing for the tag `6`. This fixes that problem and adds tests.