refactored to function based controllers and plugins
fixed tests