fixing intermittent test failures

Root cause was PG::Error: ERROR:  column reference "id" is ambiguous
also adding test for method throwing the error
fixing trailing whitespace
Merge pull request #1903 from jlsherrill/test_fix

fixing intermittent test failures