rail recursive versions of take/drop, and unit tests for stack safety