(partial-work) Added some tests and several changes