Fixes memory error in takewhile

check_current was being called in the constructor on each
Iterator creation, thus when an end iterator was created, the end was
being checked against the predicate which was one passed the end.
The fix checks for end before doing the check in the constructor.