src: bugs fixed + test