Add some tests and a proper way to run it.
Now need refactoring on the "core" side