the aim is to make the tests more about the behavior rather than implementation, add some missing tests, and improve the code.