lib: fix object reference leak, fix test suite