Do not throw errors when test already exists.

If test exists in dg_test but there is no result for it in dg_test_results then script will attempt to insert new test row. That would fail due to 'unique' constraint. This pacth corrects this: before inserting new test script verifies whether such test row already exists and returns it if it is available. Insertion happens only in case when test is in fact new.