Solve the quine problem

Also adds some tests.