Added api sort field and a few tests