Updated tests and fix some issues