added invoke controller to preview
refactered preview, fixed tests