adds tests & applies fixes