Fixing functions to return nth term, adding assert statements