Fixed hasOne relation

The hasOne relation is now tested and will correctly infer the
foreignKey if one is not provided.