Added support for group affinity, updated tests