complete index-frequencies function, write some tests

Signed-off-by: Koleman Nix <kolemannix@gmail.com>