Added a testcase. Removed some unused code.