Add first working test, refactor and fix things