Remove unused instance variable
Add some tests and do some code refactoring