fixed execution bugs and added tests