General fixes and some tests.

Some general fixes have been done, as well as some basic tests sucesfully
run.