Fixed NPEs in tests