Added tests, fucktored a bit.