Add lots of tests and pieces of implementation