Regression tests and full fix for #118

  * Based on partial fix by @stupergenius
  * Handles nil case for hasOne associations
Merge pull request #119 from pobocks/issue_118_fix

Regression tests and full fix for #118