Move running test logic to db