Various fixes and additional tests