Fixed dependency order so test is built first if HAVE_CHECK was defined so that the test library was built first.