Add test coverage and pull some logic out of #execute.