fixed indexing bug for the subhalos, added unit test