DSTC: Direct Preference Learning with Only Self-Generated Tests and Code to Improve Code LMs