Deal with cycles in RDD dependency graph + add extensive tests