fix minor goroutine leakage
add error check when saving build events
refactor db tests slightly