fixing intermittent test failures

Root cause was PG::Error: ERROR:  column reference "id" is ambiguous
also adding test for method throwing the error