Fix tests, polish code, update dependencies