add test for in-place replacement of self-loop node with node 0
bugfix: use ternary operator to replace node with self-loop in-place

because otherwise `old == target and new` with old equal to target will evaluate to new. If new is 0 (a valid integer node), then the conjunction evaluates to False, masking that old is equal to target. The ternary operator implements the selection and avoids this issue.
Merge pull request #1278 from johnyf/reinplace_selfloops

bugfix: reinplace self-loop node with 0 fails