instanceof check in defaultTo
adding several tests from recent modifications
add test for #162