Some cleaning up and implementation of more tests