Fix identical comparison of arrays with references

Also commit a test I forgot.