Minor bug fix + some tests