CPU only tests

To enable running the tests on machines with only the CPU, the GPU related codes have to be separated. 

Related issue: #468