Refactored some test code into test directory. Fixed naive test strategy