Add tickets controller tests. Also started to fix self tests of state_machine.