Fix most of the warnings. Complete the test support