remove two compiler warnings
refactor the state machine

- add support for sending messages to the state machine which will
  be received by the current state.
- don't have a state_run function to be called for the state, but only
  enter, exit, and a method to receive  messages.
- change the way of exiting the state-machine: create a new type of
  message which will be post on the same message-queue and exit
update the state-machine test

- use the new state-machine design.
- test also messages sent to a state.
- create a simple state machine with 3 states: s1, s2, s3 which
  will start in state s1 and then transit in state 2. Once being in
  s2 it will loop in s2 three times and then move to s3 after which
  it will be requested to finish. The main program will sleep
  for 2 seconds and then request the machine to finish.
add another small test for the state machine
add method to destroy the state machine
destroy the state machines used in the tests
fix state-machine uninitialzed field
fix memory leaks and other minor things

- free the allocated resources in both the state machine and the
  message queue.
- check for machine_finished flag before creating and sending
  a new EXIT message on the queue.