Added tests for ApplyToRestAfterFirst and ApplyToRestBeforeLast