Implement n_groups. Closes #477.
Also make sure group_size works for ungrouped data, and add tests