Fix codestyle and fix tests