implement basic test and fix bugs