build: improve rules for test programs