final fixes and tests