misc changes

Signed-off-by: Jonathan Galpin <jonathan@iqzero.net>
Controller refactoring

Added phpunit tests

Signed-off-by: Jonathan Galpin <jonathan@iqzero.net>