add tests and reorg src tree