guard against self-assignment
add unit tests for optional type