Complete unit tests in the core and fix a regression