Added some tests. Removed dead code