Fix issue that scaped unit tests, and added a test for it