Fix small tests and improve unit tests