Fix bugs, add new tests, improves