Small fixes and added some tests