more tests added and refactor