Fixed automatic conversion to double warning.
Added some simple tests for the function<> class.
Improved thread implementation.

* The thread is started with an indirect SVC now.
* The shared thread data uses an atomic int for the reference counter instead of a
  mutex-locked variable.
* Moved as much as possible into the source file thread.cpp.