add tests and main code