Correct and working version, tests moved to separate directory